QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#594027 | #7804. Intersegment Activation | StrausKoldun | WA | 1ms | 3716kb | C++17 | 1.3kb | 2024-09-27 18:11:34 | 2024-09-27 18:11:35 |
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 k = n;
int low = 1, high = n;
while (n && now != k)
{
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(diff(prev_code, now_code) == 0 && 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: 100
Accepted
time: 1ms
memory: 3672kb
input:
3 0 0 0 1 1 2 3
output:
1 1 1 2 1 1 2 2 2 3 2 2
result:
ok OK, 6 queries
Test #2:
score: 0
Accepted
time: 1ms
memory: 3716kb
input:
1 0 1
output:
1 1
result:
ok OK, 1 queries
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2 1 2
output:
1 1
result:
ok OK, 1 queries
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3680kb
input:
2 0 0 1 0 1
output:
1 1 1 2 1 1 2 2
result:
wrong answer format Unexpected end of file - int32 expected