QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796638 | #9783. Duloc Network | ucup-team1264# | WA | 1ms | 3840kb | C++20 | 602b | 2024-12-01 22:41:45 | 2024-12-01 22:41:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
int n;
int query(int l, int r) {
string s(n, '0');
fill(s.begin() + l - 1, s.begin() + r, '1');
cout << "? " << s << endl;
int x; cin >> x; return x;
}
bool solve(int l, int r, int out = 0) {
if (l == r) return true;
int mid = (l + r) >> 1;
int cl = query(l, mid), cr = query(mid + 1, r);
if (cl + cr == out) return false;
return solve(l, mid, cl) && solve(mid + 1, r, cr);
}
int main() {
cin >> n;
bool ans = solve(1, n);
cout << "! " << (int)ans << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
4 2 1 1 3 2 2
output:
? 1100 ? 0011 ? 1000 ? 0100 ? 0010 ? 0001 ! 1
result:
ok Correct answer with 6 queries.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
2 0 0
output:
? 10 ? 01 ! 0
result:
ok Correct answer with 2 queries.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
4 2 1 1 3 2 2
output:
? 1100 ? 0011 ? 1000 ? 0100 ? 0010 ? 0001 ! 1
result:
ok Correct answer with 6 queries.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
2 0 0
output:
? 10 ? 01 ! 0
result:
ok Correct answer with 2 queries.
Test #5:
score: 0
Accepted
time: 0ms
memory: 3760kb
input:
50 15 19 15 16 11 9 6 8 4 2
output:
? 11111111111111111111111110000000000000000000000000 ? 00000000000000000000000001111111111111111111111111 ? 11111111111110000000000000000000000000000000000000 ? 00000000000001111111111110000000000000000000000000 ? 11111110000000000000000000000000000000000000000000 ? 000000011111100000000000000000000...
result:
ok Correct answer with 10 queries.
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3480kb
input:
50 25 25 36 38 33 36 22 23 19 12 10 13 8 6 18 10 13 8 18 29 16 8 8 8
output:
? 11111111111111111111111110000000000000000000000000 ? 00000000000000000000000001111111111111111111111111 ? 11111111111110000000000000000000000000000000000000 ? 00000000000001111111111110000000000000000000000000 ? 11111110000000000000000000000000000000000000000000 ? 000000011111100000000000000000000...
result:
wrong answer Wrong answer.