Codeforces 622. Optimal Number permutation construction

Source: Internet
Author: User

Topic links

Suppose you can always find a state so that the value is 0, then two 1 requires the number of n-2, two 2 between the number of n-3, two 3 of the interval n-4 number. We found that two of the three can be placed between two 1, the same as two 5 put to two 3 .... So it's structured.

#include <iostream>#include<vector>#include<cstdio>#include<cstring>#include<algorithm>#include<cmath>#include<map>#include<Set>#include<string>#include<queue>#include<stack>#include<bitset>using namespacestd;#definePB (x) push_back (x)#definell Long Long#defineMK (x, y) make_pair (x, y)#defineLson L, M, rt<<1#defineMem (a) memset (a, 0, sizeof (a))#defineRson m+1, R, rt<<1|1#defineMem1 (a) memset (a,-1, sizeof (a))#defineMEM2 (a) memset (a, 0x3f, sizeof (a))#defineRep (i, N, a) for (int i = A; i<n; i++)#defineFi first#defineSe Secondtypedef pair<int,int>PLL;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMoD = 1e9+7;Const intINF =1061109567;Const intdir[][2] = { {-1,0}, {1,0}, {0, -1}, {0,1} };inta[1000005];intMain () {intN; CIN>>N; intL =1, r = N, cnt =1;  while(r>l) {a[l+ +] = cnt, a[r--] =CNT; CNT+=2; } l= n+1, R = l+n-2, cnt =2;  while(r>l) {a[l+ +] = cnt, a[r--] =CNT; CNT+=2; }     for(inti =1; i<=2*n; i++) {        if(A[i]) printf ("%d", A[i]); Elseprintf ("%d", N); }    return 0;}

Codeforces 622. Optimal Number permutation construction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.