QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#627308 | #6303. Inversion | TokaiZaopen# | WA | 104ms | 8124kb | C++23 | 1.4kb | 2024-10-10 15:30:30 | 2024-10-10 15:30:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
// #define int long long
map<pair<int, int>, int> mp;
int ask(int l, int r)
{
if (l == r)
{
return 0;
}
if (mp.count({l, r}))
{
return mp[{l, r}];
}
else
{
cout << "? " << l + 1 << " " << r + 1 << endl;
int x;
cin >> x;
return mp[{l, r}] = x;
}
}
int solve()
{
int n;
cin >> n;
vector<int> a(n);
iota(all(a), 0);
sort(all(a), [&](int x, int y) {
if (x < y)
{
if (x == y - 1)
{
return ask(x, y) == 0;
}
else
{
return (ask(x, y) + ask(x + 1, y - 1) - ask(x + 1, y) - ask(x, y - 1)) == 0;
}
}
else
{
swap(x, y);
if (x == y - 1)
{
return ask(x, y) != 0;
}
else
{
return (ask(x, y) + ask(x + 1, y - 1) - ask(x + 1, y) - ask(x, y - 1)) != 0;
}
}
});
vector<int> b(n);
int cnt = 1;
cout << "! ";
for (int i = 0; i < n; i++)
{
b[a[i]] = cnt++;
}
for (auto it : b)
cout << it << " ";
cout << endl;
return 0;
}
signed main()
{
int test = 1;
while (test--)
{
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
input:
3 0 0 1
output:
? 1 2 ? 1 3 ? 2 3 ! 2 3 1
result:
ok OK, guesses=3
Test #2:
score: -100
Wrong Answer
time: 104ms
memory: 8124kb
input:
1993 1 1 0 1 1 1 1 1 0 0 0 1 0 0 1 1 1 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 1 0 1 1 1 1 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 1 1 0 1 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 0 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0...
output:
? 2 997 ? 3 996 ? 3 997 ? 2 996 ? 2 1993 ? 3 1992 ? 3 1993 ? 2 1992 ? 1 2 ? 2 3 ? 3 1991 ? 2 1991 ? 2 4 ? 3 4 ? 3 1990 ? 2 1990 ? 2 5 ? 3 5 ? 2 6 ? 3 6 ? 2 7 ? 3 7 ? 2 8 ? 3 8 ? 3 1989 ? 2 1989 ? 2 9 ? 3 9 ? 2 10 ? 3 10 ? 2 11 ? 3 11 ? 2 12 ? 3 12 ? 3 1988 ? 2 1988 ? 2 13 ? 3 13 ? 3 1987 ? 2 1987 ? ...
result:
wrong output format Unexpected end of file - int32 expected