Вот мой код. Даже ускорение cin7.tie(0); убрал↵
#include <iostream>↵
using namespace std;↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
int t;↵
cin >> t;↵
for (int h = 0; h < t; h++){↵
int n; cin >> n;↵
if (n > 2){↵
for (int i = 4; i < 2 * n; i += 2){↵
cout << '?' << " " << i + 1 << " " << i + 2 << endl;↵
int k; cin >> k;↵
if (k == 1)↵
cout << '!' << " " << i + 1;↵
cout.flush();↵
}↵
}↵
int a, b, c;↵
cout << '?' << " " << 1 << " " << 2 << endl;↵
cin >> a;↵
cout.flush();↵
cout << '?' << " " << 1 << " " << 3 << endl;↵
cin >> b;↵
cout.flush();↵
cout << '?' << " " << 2 << " " << 3 << endl;↵
cin >> c;↵
cout.flush();↵
if (a == 1 || b == 1)↵
cout << '!' << " " << 1;↵
else if (c == 1)↵
cout << '!' << " " << 2;↵
else ↵
cout << '!' << " " << 4;↵
}↵
return 0;↵
}↵
Что не так?
#include <iostream>↵
using namespace std;↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
int t;↵
cin >> t;↵
for (int h = 0; h < t; h++){↵
int n; cin >> n;↵
if (n > 2){↵
for (int i = 4; i < 2 * n; i += 2){↵
cout << '?' << " " << i + 1 << " " << i + 2 << endl;↵
int k; cin >> k;↵
if (k == 1)↵
cout << '!' << " " << i + 1;↵
cout.flush();↵
}↵
}↵
int a, b, c;↵
cout << '?' << " " << 1 << " " << 2 << endl;↵
cin >> a;↵
cout.flush();↵
cout << '?' << " " << 1 << " " << 3 << endl;↵
cin >> b;↵
cout.flush();↵
cout << '?' << " " << 2 << " " << 3 << endl;↵
cin >> c;↵
cout.flush();↵
if (a == 1 || b == 1)↵
cout << '!' << " " << 1;↵
else if (c == 1)↵
cout << '!' << " " << 2;↵
else ↵
cout << '!' << " " << 4;↵
}↵
return 0;↵
}↵
Что не так?



