QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594016 | #7804. Intersegment Activation | StrausKoldun | WA | 0ms | 3556kb | C++17 | 1.3kb | 2024-09-27 18:04:40 | 2024-09-27 18:04:40 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
unsigned int grayencode(unsigned int g)
{
return g ^ (g >> 1);
}
int diff(unsigned int a, unsigned int b){
// cout << "diff" << a << " " << b << endl;
auto c = a ^ b;
int res = 0;
while(c != 1){
assert(c % 2 != 1);
c /= 2;
res++;
}
return res;
}
int zapr(int l, int r){
cout << l << " " << r << endl;
int x;
cin >> x;
return x;
}
void solve() {
int n;
cin >> n;
int now;
cin >> now;
int low = 1, high = n;
while (n)
{
int prev_code = grayencode(0);
for (int i = 1; i < (1 << n); i++)
{
// cout << "i: " << i << endl;
// cout << "1<<n: " << (1 << n) << endl;
int now_code = grayencode(i);
int new_now = zapr(low, low + diff(prev_code, now_code));
// cout << "now: " << now << endl;
// cout << "new_now:" << new_now << endl;
if(new_now != now){
if(new_now < now){
new_now = zapr(low, low + diff(prev_code, now_code));
}
now = new_now;
break;
}
prev_code = now_code;
}
low++;
n--;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3556kb
input:
3 0 0 0 1 1 2 1 2
output:
1 1 1 2 1 1 2 2 2 3 3 3 3 3
result:
wrong answer format Unexpected end of file - int32 expected