QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#210088#6303. InversiontherehelloWA 50ms19100kbC++201.1kb2023-10-11 00:49:322023-10-11 00:49:33

Judging History

你现在查看的是最新测评结果

  • [2023-10-11 00:49:33]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:19100kb
  • [2023-10-11 00:49:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;

    vector _f(n + 1, vector<int>(n + 1, -1));
    auto f = [&](int l, int r) {
        if (l >= r) return 0;
        if (_f[l][r] != -1) return _f[l][r];
        cout << "? " << l << " " << r << endl;
        int x;
        cin >> x;
        return _f[l][r] = x;
    };

    vector<int> a{1};
    for (int i = 2; i <= n; i++) {
        auto pos = lower_bound(a.begin(), a.end(), i, [&](int l, int r) {
            int x = f(l, r) - f(l + 1, r) - f(l, r - 1) + f(l + 1, r - 1);
            x = (x % 2 + 2) % 2;
            return !x;
        });
        a.insert(pos, i);
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) ans[a[i] - 1] = i + 1;

    cout << "! ";
    for (auto& i : ans) cout << i << " ";
    cout << endl;
}

int main() {
    ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (t--) solve();
#ifdef DEBUG
    cout << "\n----------------\n";
    cout << fixed << setprecision(6);
    cout << "Times: " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
#endif
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3588kb

input:

3
0
1
0

output:

? 1 2
? 2 3
? 1 3
! 2 3 1 

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 50ms
memory: 19100kb

input:

1993
0
0
0
0
0
1
1
0
0
0
0
0
0
1
0
1
0
0
1
0
0
0
1
1
1
0
1
1
0
0
1
1
1
1
1
1
1
0
0
1
1
1
1
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
1
0
1
0
0
1
0
1
1
1
1
0
0
1
1
0
1
0
0
0
0
0
1
1
0
1
1
1
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
0
1
1
0
0
0
0
1
1
1
0
1
0
0
0
1
0
0
1
1
0
0
1
1
1
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
0
0
1
0...

output:

? 1 2
? 2 3
? 2 4
? 3 4
? 3 5
? 4 5
? 2 5
? 1 5
? 1 4
? 2 6
? 3 6
? 1 6
? 5 6
? 2 7
? 3 7
? 6 7
? 5 7
? 1 8
? 2 8
? 1 7
? 3 8
? 4 8
? 4 7
? 2 9
? 3 9
? 6 9
? 7 9
? 6 8
? 7 8
? 1 9
? 9 10
? 6 10
? 7 10
? 5 10
? 5 9
? 8 10
? 8 9
? 9 11
? 10 11
? 5 11
? 6 11
? 1 11
? 2 11
? 1 10
? 2 10
? 11 12
? 8 12
?...

result:

wrong output format Unexpected end of file - int32 expected