QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#244622#6303. Inversionhhoppitree#WA 29ms19512kbC++14891b2023-11-09 13:46:022023-11-09 13:46:03

Judging History

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

  • [2023-11-09 13:46:03]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:19512kb
  • [2023-11-09 13:46:02]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int N = 2005;

int a[N], b[N], f[N][N];

int query(int l, int r)
{
    if (~f[l][r]) {
        return f[l][r];
    }
    if (l >= r) {
        return 0;
    }
    printf("? %d %d\n", l, r);
    int x;
	fflush(stdout);
    scanf("%d", &x);
    return f[l][r] = x;
}

int cmp(int l, int r)
{
    if (l > r) {
        return !cmp(r, l);
    }
    return query(l, r) ^ query(l + 1, r) ^ query(l, r - 1) ^ query(l + 1, r - 1);
}

signed main()
{
    int n;
    scanf("%d", &n);
    memset(f, -1, sizeof(f));
    for (int i = 1; i <= n; ++i) {
        a[i] = i;
    }
    stable_sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; ++i) {
        b[a[i]] = n - i + 1;
    }
    printf("!");
    for (int i = 1; i <= n; ++i) {
        printf(" %d", b[i]);
    }
    puts("");
    return 0;
}

詳細信息

Test #1:

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

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: 29ms
memory: 19496kb

input:

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

output:

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

result:

wrong output format Unexpected end of file - int32 expected