QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#573223 | #8239. Mysterious Tree | Panjy | WA | 3ms | 3820kb | C++17 | 3.6kb | 2024-09-18 17:48:29 | 2024-09-18 17:48:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define all1(x) x.begin() + 1, x.end()
#define bit1(x) __builtin_popcountll(x)
#define Pqueue priority_queue
#define lc p << 1
#define rc p << 1 | 1
#define IOS ios::sync_with_stdio(false), cin.tie(0);
#define fi first
#define se second
#define lowbit(x) (x & -x)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<ll, ll> PII;
const ll mod = 1000000007;
const ll N = 1e6 + 10;
const ld eps = 1e-9;
const ll inf = 1e18;
const ll P = 131;
const ll dir[8][2] = {1, 0, 0, 1, -1, 0, 0, -1, 1, 1, 1, -1, -1, 1, -1, -1};
void solve()
{
auto ask = [&](int a, int b)
{
cout << "? " << a << " " << b << endl;
int op = 1;
cin >> op;
return op;
};
int n;
cin >> n;
vector<array<int, 2>> q;
if (n & 1)
if (ask(n - 1, n))
q.push_back({n - 1, n});
for (int i = 2; i <= n; i += 2)
if (ask(i - 1, i))
q.push_back({i - 1, i});
if (q.size() == 0)
return void(cout << "! 1" << endl);
if (q[0][1] == n)
{
bool flag = ask(1, n);
if (flag)
{
bool flag1 = ask(2, n);
if (flag1)
cout << "! 2" << endl;
else
cout << "! 1" << endl;
}
else
{
bool flag1 = ask(1, n - 1);
if (!flag1)
cout << "! 1" << endl;
else
{
bool flag2 = ask(2, n - 1);
if (!flag2)
cout << "! 1" << endl;
else
cout << "! 2" << endl;
}
}
}
else
{
bool flag = ask(q[0][0], n);
if (flag)
{
bool flag1 = ask(q[0][0], n - 1);
if (flag1)
cout << "! 2" << endl;
else
cout << "! 1" << endl;
}
else
{
bool flag1 = ask(q[0][1], n);
if (!flag1)
cout << "! 1" << endl;
else
{
bool flag2 = ask(q[0][1], n - 1);
if (!flag2)
cout << "! 1" << endl;
else
cout << "! 2" << endl;
}
}
}
}
int main()
{
int T = 1;
cin >> T;
while (T--)
solve();
return 0;
}
/*
oxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxox
x o
o _/_/_/_/ _/ x
x _/ o
o _/_/_/_/ _/ _/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/_/ _/_/_/ _/ _/ _/ x
x _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ o
o _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ x
x _/ _/ _/_/ _/ _/ _/ _/_/_/ _/_/ _/ _/ _/ _/ _/ o
o _/ _/ _/ x
x _/ _/_/ _/ o
o x
xoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxoxo
*/
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
2 4 1 1 0 0 4 0 1 0 1 1
output:
? 1 2 ? 3 4 ? 1 4 ? 2 4 ! 1 ? 1 2 ? 3 4 ? 1 4 ? 1 3 ? 2 3 ! 2
result:
ok Correct (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3820kb
input:
87 13 1 0 0 0 0 0 1 0 1 1 15 0 0 0 0 0 0 0 1 1 1 7 1 0 0 0 1 1 15 0 0 0 0 1 1 0 0 0 1 0 19 0 0 0 0 0 0 1 0 0 0 1 1 20 0 0 0 0 0 0 0 0 0 0 7 1 0 0 1 0 1 1 20 0 0 0 0 0 0 0 1 0 0 1 1 17 0 0 0 0 0 0 0 0 0 11 1 1 1 0 0 0 0 0 14 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 18 0 0 0 0 0 1 0 0 0 0 1 1 14 0 1 0 0 0 0 0 0...
output:
? 12 13 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 1 13 ? 1 12 ? 2 12 ! 2 ? 14 15 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 13 15 ? 13 14 ! 2 ? 6 7 ? 1 2 ? 3 4 ? 5 6 ? 1 7 ? 2 7 ! 2 ? 14 15 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ? 9 10 ? 11 12 ? 13 14 ? 7 15 ? 8 15 ? 8 14 ! 1 ? 18 19 ? 1 2 ? 3 4 ? 5 6 ? 7 8 ?...
result:
wrong answer Wrong prediction (test case 34)