QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180006#6303. Inversionucup-team045#WA 17ms19504kbC++201.7kb2023-09-15 14:34:082023-09-15 14:34:08

Judging History

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

  • [2023-09-15 14:34:08]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:19504kb
  • [2023-09-15 14:34:08]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<random>
using namespace std;
using LL = long long;
int dp[2005][2005];

int main(){

// #ifdef LOCAL
//     freopen("data.in", "r", stdin);
//     freopen("data.out", "w", stdout);
// #endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);

    auto ask = [&](int l, int r){
        if (l >= r) return 0;
        if (dp[l][r] != -1) return dp[l][r];
        cout << "? " << l + 1 << ' ' << r + 1 << endl;
        int t;
        cin >> t;
        return dp[l][r] = t;
    };
    vector<int> id(n);
    for(int i = 0; i < n; i++) id[i] = i;
    mt19937 rnd(random_device{}());
    shuffle(id.begin(), id.end(), rnd);
    vector<int> c{id[0]};
    for(int i = 1; i < id.size(); i++){

        auto check = [&](int a, int b){
            if (a < b){
                int c1 = ask(a, b);
                int c2 = ask(a + 1, b);
                int c3 = ask(a, b - 1);
                int c4 = ask(a + 1, b - 1);
                return c1 ^ c2 ^ c3 ^ c4;
            }
            swap(a, b);
            int c1 = ask(a, b);
            int c2 = ask(a + 1, b);
            int c3 = ask(a, b - 1);
            int c4 = ask(a + 1, b - 1);
            return c1 ^ c2 ^ c3 ^ c4 ^ 1;
        };

        int l = 0, r = i;
        while(l < r){
            int mid = (l + r) / 2;
            if (check(c[l], id[i])) r = mid;
            else l = mid + 1; 
        }
        c.insert(c.begin() + r, id[i]);
    }
    vector<int> ans(n);
    for(int i = 0; i < c.size(); i++)
        ans[c[i]] = i;
    cout << "! ";
    for(auto x : ans) cout << x + 1 << ' ';
    cout << endl;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 19504kb

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: 17ms
memory: 19300kb

input:

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

output:

? 642 1706
? 643 1706
? 642 1705
? 643 1705
? 642 792
? 643 792
? 642 791
? 643 791
? 642 1764
? 643 1764
? 642 1763
? 643 1763
? 792 1764
? 793 1764
? 792 1763
? 793 1763
? 305 642
? 306 642
? 305 641
? 306 641
? 305 1764
? 306 1764
? 305 1763
? 306 1763
? 642 1213
? 643 1213
? 642 1212
? 643 1212
...

result:

wrong answer Wa.