QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#371269 | #7804. Intersegment Activation | FOY# | RE | 0ms | 0kb | C++23 | 905b | 2024-03-30 03:53:31 | 2024-03-30 03:53:31 |
answer
#include <iostream>
#include <vector>
#include <bitset>
#include <cassert>
using namespace std;
vector<int> gray(int n) {
vector<int> gray = {0};
for (int i = 1; i < n; i++) {
gray.push_back(i);
for (int j = gray.size()-2; j >= 0; j--) gray.push_back(gray[j]);
}
gray.push_back(n-1);
return gray;
}
int main() {
int n; cin >> n;
int val;
for (int i = 0; i < n; i++) {
int best = 0, bestMask = 0;
int mask = 0;
auto g = gray(n-i);
for (int j = 0; j < g.size(); j++) {
cout << i+1 << ' ' << i+1+g[j] << endl;
mask ^= (1<<g[j]);
cin >> val;
if (val == n) return 0;
if (val > best) {
best = val;
bestMask = mask;
}
}
assert(mask == 0);
while (bestMask) {
cout << i+1 << ' ' << i+__builtin_ctz(bestMask)+1 << endl;
bestMask -= 1<<__builtin_ctz(bestMask);
int val; cin >> val;
}
}
assert(val == n);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0
output:
1 1 1 2 1 1 1 3 1 1 1 2 1 1 1 3 1 2 1 3 2 2 2 3 2 2 2 3 3 3 3 3