QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627315#7804. Intersegment ActivationIllusionaryDominance#RE 0ms0kbC++201.3kb2024-10-10 15:31:462024-10-10 15:31:46

Judging History

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

  • [2024-10-10 15:31:46]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-10 15:31:46]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 10 + 5;

int ask(int i, int j) {
    printf("%d %d\n", i, j);
    fflush(stdout);
    int res;
    scanf("%d", &res);
    return res;
}

int gray_code[1 << 12], lowbit[1 << 12];

void gen_code(int n) {
    gray_code[0] = 0;
    for (int i = 1; i <= n; i ++) {
        for (int j = (1 << i - 1), k = (1 << i - 1) - 1; j < (1 << i); j ++, k --) {
            gray_code[j] = gray_code[k] | 1 << i - 1;
        }
    }
}

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1, j = 1; i <= n; i <<= 1, j ++) lowbit[i] = j;
    for (int i = 0; i < n; i ++) {
        for (int j = i + 1; j <= n; j ++) {
            int res = ask(j, j);
            if (res > k) {
                assert(k == ask(j, j));
            }else {
                k = res;
            }
        }
        assert(k == i);
        gen_code(n - i);
        for (int j = 1; j < (1 << n - i); j ++) {
            int diff = gray_code[j] ^ gray_code[j - 1];
            assert(diff == (diff & -diff));
            int res = ask(i + 1, i + lowbit[diff]);
            if (res > k) {
                k = res;
                break;
            }
        }
    }
    assert(k == n);
    return 0;
}

详细

Test #1:

score: 0
Runtime Error

input:

3
0
0
0
0
0
1
1
1
1
2
1

output:

1 1
2 2
3 3
1 1
1 2
2 2
3 3
2 2
2 3
3 3

result: