QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455911#8819. CNOI Knowledgeucup-team4074WA 0ms3660kbC++14722b2024-06-27 00:04:322024-06-27 00:04:33

Judging History

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

  • [2024-06-27 00:04:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3660kb
  • [2024-06-27 00:04:32]
  • 提交

answer

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

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: 0
Wrong Answer
time: 0ms
memory: 3660kb

input:

12
3
3
6
6
10
6
10
15
10
15
21
10
20
15
14
6
9
14
6
10
19
5
2
19
5
3
25
9
3
6

output:

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

result:

wrong answer Wrong Answer.