#line 1 "Main.cpp" #line 1 "Main.cpp" #include #include #include #include #include #include #include #line 1 "nachia\\misc\\bit-operations.hpp" #line 4 "nachia\\misc\\bit-operations.hpp" namespace nachia{ int Popcount(unsigned long long c) noexcept { #ifdef __GNUC__ return __builtin_popcountll(c); #else c = (c & (~0ull/3)) + ((c >> 1) & (~0ull/3)); c = (c & (~0ull/5)) + ((c >> 2) & (~0ull/5)); c = (c & (~0ull/17)) + ((c >> 4) & (~0ull/17)); c = (c * (~0ull/257)) >> 56; return c; #endif } // please ensure x != 0 int MsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return 63 - __builtin_clzll(x); #else int res = 0; for(int d=32; d>=0; d>>=1) if(x >> d){ res |= d; x >>= d; } return res; #endif } // please ensure x != 0 int LsbIndex(unsigned long long x) noexcept { #ifdef __GNUC__ return __builtin_ctzll(x); #else return msb_idx(x & -x); #endif } } #line 9 "Main.cpp" using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; namespace Segtree { using S = int; S e(){ return 0; } S op(S l, S r){ return l | r; } using RQ = atcoder::segtree; } int main(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; Segtree::RQ rq(A); int allxor = 0; for(int a : A) allxor ^= a; auto readMove = [&]() -> bool { int i,k; cin >> i >> k; i--; allxor ^= A[i]; A[i] -= k; allxor ^= A[i]; rq.set(i, A[i]); int r; cin >> r; return r == -1; }; auto doMove = [&](){ int msb = 1 << nachia::MsbIndex(allxor); int i = rq.max_right(0, [&](int x){ return 0 == (msb & x); }); allxor ^= A[i]; int k = A[i] - allxor; cout << (i+1) << ' ' << k << endl; A[i] -= k; rq.set(i, A[i]); allxor ^= A[i]; int r; cin >> r; return r == -1; }; if(allxor != 0){ cout << 1 << endl; } else { cout << 0 << endl; if(readMove()) return 0; } while(true){ if(doMove()) return 0; if(readMove()) return 0; } return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;