QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488874#8819. CNOI Knowledgedalao_see_meWA 1ms3864kbC++141.4kb2024-07-24 16:02:052024-07-24 16:02:05

Judging History

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

  • [2024-07-24 16:02:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3864kb
  • [2024-07-24 16:02:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int read() {
    int x = 0, f = 1; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9') {x = x * 10 + (c ^ 48); c = getchar();}
    return x * f;
}
const int N = 1005;
int n;
int a[N][N], b[N], c[N];
int ask(int l, int r) {
    if (~a[l][r]) return a[l][r];
    printf("? %d %d\n", l, r); fflush(stdout);
    return a[l][r] = read();
}
void Solve() {
    n = read();
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            a[i][j] = -1;
    for (int i = 1; i <= n; i++) a[i][i - 1] = 0;
    int tot = 0;
    c[1] = 1;
    for (int i = 2; c[i - 1] <= n; i++) c[i] = c[i - 1] << 1;
    for (int i = 1, j = 0, k; i <= n; i++) {
        while (c[j + 1] < i) j++; k = j;
        while (k && ask(c[k], i) - ask(c[k], i - 1) == i - c[k] + 1) k--;
        if (!k) {b[i] = ++tot; continue;}
        int L = c[k], R = min(i, c[k + 1]) - 1;
        while (L < R) {
            int mid = L + R + 1 >> 1;
            if (ask(mid, i) - ask(mid, i - 1) == i - mid + 1) L = mid;
            else R = mid - 1;
        }
        b[i] = b[L];
    }
    putchar('!');
    for (int i = 1; i <= n; i++) printf(" %d", b[i]); putchar('\n');
}
int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    int _ = 1;
    while (_--) Solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3864kb

input:

12
3
1
3
1
6
6
10
3
1
10
15
6
15
21
10
20
15
10
14
6
3
3
1
3
1
20
34
26
43
34
5
2
1
8
5
3
1
13
40
33
25
19
31
25

output:

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

result:

wrong answer Wrong Answer.