QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627315 | #7804. Intersegment Activation | IllusionaryDominance# | RE | 0ms | 0kb | C++20 | 1.3kb | 2024-10-10 15:31:46 | 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;
}
Details
Tip: Click on the bar to expand more detailed information
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