QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#180048#6303. Inversionucup-team045#WA 32ms19528kbC++201.4kb2023-09-15 15:02:182023-09-15 15:02:18

Judging History

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

  • [2023-09-15 15:02:18]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:19528kb
  • [2023-09-15 15:02:18]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<random>
#include<algorithm>
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;

    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;
    };

    stable_sort(id.begin(), id.end(), [&](int x, int y){
        return !check(x, y);
    });

    vector<int> ans(n);
    for(int i = 0; i < n; i++)
        ans[id[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: 19528kb

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: 32ms
memory: 19292kb

input:

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

output:

? 1 2
? 1 3
? 2 3
? 1 4
? 2 4
? 3 4
? 1 5
? 2 5
? 5 6
? 4 6
? 4 5
? 3 6
? 3 5
? 2 6
? 1 6
? 5 7
? 6 7
? 8 9
? 9 10
? 10 11
? 8 11
? 9 11
? 8 10
? 10 12
? 11 12
? 8 12
? 9 12
? 10 13
? 11 13
? 8 13
? 9 13
? 10 14
? 11 14
? 13 14
? 8 14
? 9 14
? 12 14
? 12 13
? 15 16
? 15 17
? 16 17
? 17 18
? 16 18
? ...

result:

wrong output format Unexpected end of file - int32 expected