QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#488835#8819. CNOI Knowledgedalao_see_meWA 0ms3960kbC++141.2kb2024-07-24 15:40:422024-07-24 15:40:43

Judging History

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

  • [2024-07-24 15:40:43]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3960kb
  • [2024-07-24 15:40:42]
  • 提交

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];
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;
    for (int i = 1; i <= n; i++) {
        int L = 0, R = i - 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;
        }
        if (L) b[i] = b[L];
        else b[i] = ++tot;
    }
    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: 0ms
memory: 3960kb

input:

12
3
1
6
6
3
10
10
15
10
6
21
15
27
20
15
14
10
6
3
9
6
20
34
26
43
34
19
14
9
6
5
3
2
1
25
8
5
25
19
9
19
13

output:

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

result:

wrong answer Invalid output.