QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455917#8819. CNOI Knowledgeucup-team4074WA 7ms3696kbC++14815b2024-06-27 00:09:402024-06-27 00:09:41

Judging History

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

  • [2024-06-27 00:09:41]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3696kb
  • [2024-06-27 00:09:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, cnt(0), col[N];
int check(int l, int r) {
    if (l == r)return 1;
    int x, y;
    cout << "? " << l << " " << r << '\n';
    cout.flush();
    cin >> x;
    cout << "? " << l << " " << r - 1 << '\n';
    cout.flush();
    cin >> y;
    return x - y == r - l + 1;
}

signed main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int l(1), r(i);
        while (l < r) {
            int mid((l + r) >> 1);
            if (check(mid, i))r = mid;
            else l = mid + 1;
        }
        if (l == 1) {
            col[i] = ++cnt;
        } else col[i] = col[l - 1];
//        cout << col[i] << '\n';
    }
    cout << "! ";
    for (int i = 1; i <= n; i++)cout << col[i] << " ";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3696kb

input:

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

output:

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

result:

ok Accepted. 62 queries used.

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3692kb

input:

1000
3
1
2
1
3
2
2
1
5
2
7
3
11
7
8
5
2
1
7
5
2
1
11
7
5
2
7
3
11
7
5
3
3
1
15
11
5
3
2
1
15
11
3
2
2
1
19
15
4
3
2
1
17
14
4
3
2
1
20
17
4
3
2
1
15
13
4
3
2
1
23
15
9
4
13
6
15
7
23
15
11
7
5
3
3
1
31
23
11
8
5
3
3
1
36
27
11
7
5
3
2
1
45
36
15
11
3
2
2
1
48
39
15
11
5
2
7
3
11
7
58
48
16
11
5
3
2
...

output:

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

result:

wrong answer Too many queries.