Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int,int>
- #define vec vector
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v){
- for (auto x: v) {
- cout<<x<<' ';
- }
- cout<<"\n";
- }
- void cvl(vector <ll> &v){
- for (auto x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvv(vector <vector <int> > &v){
- for (auto x: v) cv(x);
- cout<<"\n";
- }
- void cvb(vector <bool> v){
- for (bool x: v) cout<<x<<' ';
- cout<<"\n";
- }
- void cvs(vector <string> v){
- for (auto a: v){
- cout<<a<<"\n";
- }
- }
- void cvp(vector <pii> a){
- for (auto p: a){
- cout<<p.first<<' '<<p.second<<"\n";
- }
- cout<<"\n";
- }
- bool sh=1;
- int n, N;
- // n = 1 - отдельно
- void ask(int a, int b){
- cout<<"? "<< (a)<<' '<<(b)<<"\n";
- //cout.flush();
- }
- void slv(){
- vector <int> a,b;
- for (int i = 1; i <= pow(2,n); ++i){
- a.push_back(i);
- }
- while (a.size() >= 4){
- if (sh){
- cout<<"a\n";
- cv(a);
- }
- n = a.size();
- for (int i = 0; i + 3 < n; i+=4){
- if (sh){
- cout<<"i = "<<i<<"\n";
- cout<<"a\n";
- cv(a);
- }
- ask(a[i], a[i+2]);
- int r;
- cin>>r;
- int w1, w2, w;
- if (r == 0){
- w1 = a[i+1];
- w2 = a[i + 3];
- }
- else if (r == 1){
- w1 = a[i];
- w2 = a[i + 3];
- }
- else if (r == 2){
- w1 = a[i + 1];
- w2 = a[i + 2];
- }
- w = w1;
- ask(w1, w2);
- cin>>r;
- if (r == 2){
- w = w2;
- }
- b.push_back(w);
- a = b;
- b.clear();
- if (sh){
- }
- }
- }
- ask(a[0], a[1]);
- int r; cin>>r;
- if (r == 1){
- cout<<a[0]<<"\n";
- }
- else{
- cout<<a[1]<<"\n";
- }
- }
- int main()
- {
- /*ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);*/
- int t=1;
- if (!sh) cin>>t;
- for (int go = 0; go < t; ++go){
- cin>>n;
- slv();
- }
- }
- /*
- 1
- 3
- ? 1 3
- 0
- ? 1 4
- 1
- ? 5 7
- 0
- ? 5 8
- 2
- ? 1 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement