QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#361592#6303. Inversionrecollector#WA 56ms19376kbC++201.4kb2024-03-23 11:48:282024-03-23 11:48:30

Judging History

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

  • [2024-03-23 11:48:30]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:19376kb
  • [2024-03-23 11:48:28]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <iostream>
#include <queue>
typedef long long LL;
using namespace std;
inline int read() {
    int num = 0 ,f = 1; char c = getchar();
    while (!isdigit(c)) f = c == '-' ? -1 : f ,c = getchar();
    while (isdigit(c)) num = (num << 1) + (num << 3) + (c ^ 48) ,c = getchar();
    return num * f;
}
const int N = 2005;
int res[N][N];
inline int ask(int l ,int r) {
    if (l >= r) return 0;
    if (res[l][r] != -1) return res[l][r];
    cout << "? " << l << ' ' << r << endl;
    int x = 0; cin >> x; return res[l][r] = x;
}
inline bool cmp(int i ,int j) {
    return ask(i ,j) ^ ask(i + 1 ,j) ^ ask(i ,j - 1) ^ ask(i + 1 ,j - 1);
}
int a[N] ,p[N] ,n;
signed main() {
    memset(res ,-1 ,sizeof(res));
    cin >> n;
    a[1] = 1;
    for (int i = 2; i <= n; i++) {
        int p = 0;
        if (cmp(a[1] ,i)) p = 0;
        else {
            int l = 1 ,r = i - 1;
            while (l < r) {
                int mid = (l + r + 1) >> 1;
                if (cmp(a[mid] ,i)) r = mid - 1;
                else l = mid;
            }
            p = l;
        }
        for (int j = i - 1; j > p; j--) a[j + 1] = a[j];
        a[p + 1] = i;
    }
    for (int i = 1; i <= n; i++) p[a[i]] = i;
    cout << "! ";
    for (int i = 1; i <= n; i++) cout << p[i] << ' ';
    cout << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 56ms
memory: 19376kb

input:

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

output:

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

result:

wrong output format Unexpected end of file - int32 expected