fork download
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. const int maxn = 1e5 + 50;
  7.  
  8. int n , x;
  9. vector < int > rx;
  10.  
  11. bool Solve(){
  12. random_shuffle( rx.begin() , rx.end() );
  13. int w = 0;
  14. for(int i = 0 ; i < n - 1 ; ++ i) w ^= rx[i];
  15. int an = x ^ w;
  16. for(int i = 0 ; i < n - 1 ; ++ i)
  17. if( an == rx[i] )
  18. return false;
  19. if( an > 1e6 ) return false;
  20. return true;
  21. }
  22.  
  23. int main( int argc , char * argv[] ){
  24. //freopen( "Sample" , "r" , stdin );
  25. srand( time( NULL ) );
  26. for(int i = 0 ; i <= 1000000 ; ++ i) rx.emplace_back( i );
  27. cin >> n >> x;
  28. if( n == 2 && x == 0 ){
  29. puts( "NO" );
  30. return 0;
  31. }
  32. printf( "YES\n" );
  33. if( n == 1 ) printf( "%d\n" , x );
  34. else{
  35. while( !Solve( ) );
  36. int w = x;
  37. for(int i = 0 ; i < n - 1 ; ++ i) printf( "%d " , rx[i] ) , w ^= rx[i];
  38. printf( "%d\n" , w );
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0.02s 15240KB
stdin
Standard input is empty
stdout
YES
0