Topic links:
http://codeforces.com/contest/1174/problem/D
Meaning of the questions:
A sequence configuration satisfies the following conditions
- His XOR value of all the sub-segments is not equal to $ x $
- $1 \le a_i<2^n$
A maximum output of such a sequence
data range:
$ 1 \ n \ the $ 18
$ 1 \ the x <2 ^ {18} $
analysis:
When the game confused $ subsegment $ and $ subsequence $, former sub-paragraph must be continuous, the latter sequence may be discontinuous
After the match official to see the solution to a problem
Sequence hypotheses is configured $ a_i $, it is a prefix and XOR $ $ B_i
即:$b_i=a_1\bigoplus a_2 \bigoplus a_3\bigoplus a_4.....\bigoplus a_i$
$ B_i $ must meet the following criteria
- No repeated elements namely $ b_i \ neq b_j $
- Not one of the elements of the exclusive OR value of $ X $
- There is no $ x $
On the second, we can know that if $ g $ array added $ b $, then $ g \ bigoplus x $ is not $ b $ array, so choose which one of these two numbers on the line
After obtaining the array b $ a_i = b_i \ oplus b_ {i-1} $
ac Code:
#include<bits/stdc++.h> #define ll long long #define pa pair<int,int> using namespace std; const int maxn=1e5+10; const int maxm=1e6+10; const ll mod=998244353; int ans[maxn]; inline ll cal(int st,int len) { return (ll)len*(2*st+len-1)/2; } int main() { int n,k; while(scanf("%d %d",&n,&k)==2) { if(cal(1,k)>n) { printf("NO\n"); continue; } if(n==4&&k==2) { printf("NO\n"); continue; } else if(n==8&&k==3) { printf("NO\n"); continue; } int st=1,en=n; while(st!=en) { int md=(st+en)/2; if(cal(md+1,k)<=n)st=md+1; else en=md; } for(int i=1;i<=k;i++) ans[i]=st+i-1; int now=n-cal(st,k),inde=k; while(now) { if(ans[inde]+1<=2*ans[inde-1])ans[inde]++,inde--,now--; else inde=k; } printf("YES\n"); for(int i=1;i<=k;i++) { printf("%d",ans[i]); if(i==k)printf("\n"); else printf(" "); } } return 0; }