Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.16 KB | None | 0 0
  1. #define FAST_ALLOCATOR_MEMORY 2e8
  2. //#define _GLIBCXX_DEBUG
  3. #include <bits/stdc++.h>
  4. //#include <optimization.h>
  5. #pragma GCC optimize("O3")
  6. #define chervyak 6
  7. #define sasha chervyak
  8. #define y1 jhgfds
  9. #define rank zhimba
  10. //#define count zashodeda
  11. #define prev maAslo
  12. #define hash akakzhit
  13. #define ll long long
  14. //#define int long long
  15. //#define ull uint64_t
  16. #define ld long double
  17. #define pb push_back
  18. #define eb emplace_back
  19. #define all(v) v.begin(), v.end()
  20. #define rep(i, n) for(int i = 0; i < n; i++)
  21.  
  22. using namespace std;
  23. //freopen("input.txt", "r", stdin);
  24. //freopen("output.txt", "w", stdout);
  25. //cout << clock()*1000/CLOCKS_PER_SEC << '\n';
  26. //mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
  27.  
  28. int b;
  29.  
  30. int get(int i){
  31.     assert(i >= 1 && i <= b);
  32.     cout << i << '\n';
  33.     cout.flush();
  34.     char c;
  35.     cin >> c;
  36.     if(c == 'N') exit(0);
  37.     return (c - '0');
  38. }
  39.  
  40. int a[105];
  41.  
  42. void complement(){
  43.     rep(i, b){
  44.         if(a[i] != -1) i[a] = 1 - a[i];
  45.     }
  46. }
  47.  
  48.  
  49. int32_t main(){
  50.     //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  51.     int t;
  52.     cin >> t >> b;
  53.     assert(b % 2 == 0);
  54.     rep(_, t){
  55.         rep(i, b) a[i] = -1;
  56.         int c = 1;
  57.         int x = -1, y = -1;
  58.         for(int i = 0; i < b / 2; i++){
  59.             if(c % 10 == 1 && c > 1){
  60.                 if(x != -1){
  61.                     if(y != -1){
  62.                         int was_x = a[x], was_y = a[y];
  63.                         int now_x = get(x+1), now_y = get(y+1);
  64.                         if(was_x == now_x){
  65.                             if(was_y == now_y){
  66.                                 // nothing
  67.                             }else{
  68.                                 reverse(a, a + b);
  69.                             }
  70.                         }else{
  71.                             if(was_y == now_y){
  72.                                 reverse(a, a + b);
  73.                                 complement();
  74.                             }else{
  75.                                 complement();
  76.                             }
  77.                         }
  78.                     }else{
  79.                         // 111....111
  80.                         int was = a[x];
  81.                         int now = get(x+1);
  82.                         if(was != now) complement();
  83.                         get(x+1);
  84.                     }
  85.                 }else{
  86.                     if(y != -1){
  87.                         // 000...111
  88.                         int was = a[y];
  89.                         int now = get(y+1);
  90.                         if(was != now) complement();
  91.                         get(y+1);
  92.                     }else{
  93.                         assert(false);
  94.                     }
  95.                 }
  96.                
  97.                 c += 2;
  98.             }
  99.             a[i] = get(i+1);
  100.             a[b-i-1] = get(b - i);
  101.             if(a[i] == a[b-i-1] && x == -1) x = i;
  102.             if(a[i] != a[b-i-1] && y == -1) y = i;
  103.  
  104.             c += 2;
  105.         }
  106.         rep(i, b) { assert(a[i] != -1); cout << a[i]; }
  107.         cout << '\n';
  108.         cout.flush();
  109.         char c2;
  110.         cin >> c2;
  111.         if(c2 == 'N') exit(0);
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement