Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FAST_ALLOCATOR_MEMORY 2e8
- //#define _GLIBCXX_DEBUG
- #include <bits/stdc++.h>
- //#include <optimization.h>
- #pragma GCC optimize("O3")
- #define chervyak 6
- #define sasha chervyak
- #define y1 jhgfds
- #define rank zhimba
- //#define count zashodeda
- #define prev maAslo
- #define hash akakzhit
- #define ll long long
- //#define int long long
- //#define ull uint64_t
- #define ld long double
- #define pb push_back
- #define eb emplace_back
- #define all(v) v.begin(), v.end()
- #define rep(i, n) for(int i = 0; i < n; i++)
- using namespace std;
- //freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- //cout << clock()*1000/CLOCKS_PER_SEC << '\n';
- //mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
- int b;
- int get(int i){
- assert(i >= 1 && i <= b);
- cout << i << '\n';
- cout.flush();
- char c;
- cin >> c;
- if(c == 'N') exit(0);
- return (c - '0');
- }
- int a[105];
- void complement(){
- rep(i, b){
- if(a[i] != -1) i[a] = 1 - a[i];
- }
- }
- int32_t main(){
- //ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- int t;
- cin >> t >> b;
- assert(b % 2 == 0);
- rep(_, t){
- rep(i, b) a[i] = -1;
- int c = 1;
- int x = -1, y = -1;
- for(int i = 0; i < b / 2; i++){
- if(c % 10 == 1 && c > 1){
- if(x != -1){
- if(y != -1){
- int was_x = a[x], was_y = a[y];
- int now_x = get(x+1), now_y = get(y+1);
- if(was_x == now_x){
- if(was_y == now_y){
- // nothing
- }else{
- reverse(a, a + b);
- }
- }else{
- if(was_y == now_y){
- reverse(a, a + b);
- complement();
- }else{
- complement();
- }
- }
- }else{
- // 111....111
- int was = a[x];
- int now = get(x+1);
- if(was != now) complement();
- get(x+1);
- }
- }else{
- if(y != -1){
- // 000...111
- int was = a[y];
- int now = get(y+1);
- if(was != now) complement();
- get(y+1);
- }else{
- assert(false);
- }
- }
- c += 2;
- }
- a[i] = get(i+1);
- a[b-i-1] = get(b - i);
- if(a[i] == a[b-i-1] && x == -1) x = i;
- if(a[i] != a[b-i-1] && y == -1) y = i;
- c += 2;
- }
- rep(i, b) { assert(a[i] != -1); cout << a[i]; }
- cout << '\n';
- cout.flush();
- char c2;
- cin >> c2;
- if(c2 == 'N') exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement