QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#827862 | #9783. Duloc Network | Zawos | WA | 2ms | 3744kb | C++20 | 1.7kb | 2024-12-23 10:51:24 | 2024-12-23 10:51:26 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vii = vector<ii>;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define pb(x) push_back(x)
int ask(string s) {
cout << "? " << s << endl;
int res; cin >> res;
return res;
}
string OR(string &a, string &b) {
int n = a.size();
string res(n, '0');
rep(i, 0, n)
res[i] = "01"[a[i] == '1' || b[i] == '1'];
return res;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
if (n == 1) return cout << "! 1" << endl, 0;
string A(n, '0'), B(n, '1');
A[0] = '1'; B[0] = '0';
int fA = ask(A);
if (fA == 0) {
return cout << "! 0" << endl, 0;
}
rep(i, 0, n - 1) {
int l = 0, r = n - 1;
// 1 - 2 - 3 - 4 - 5
while (l <= r) {
int m = (l + r) / 2;
string query(n, '0');
int cnt = 0;
rep(j, l, m + 1) {
query[j] = B[j];
if (B[j] == '1')
cnt++;
}
if (!cnt) {
l = m + 1;
continue;
}
int fB = ask(query), fAB = fA + ask(OR(A, query));
if (!fB) return cout << "! 0" << endl, 0;
if (fA + fB == fAB)
l = m + 1;
else
r = m - 1;
}
if (l == n) return cout << "! 0" << endl, 0;
A[l] = '1';
B[l] = '0';
fA = ask(A);
}
cout << "! 1" << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3596kb
input:
4 1 3 2 2 2 1 1 2 0 0
output:
? 1000 ? 0100 ? 1100 ? 1100 ? 0010 ? 1110 ? 1110 ? 0001 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 10 queries.
Test #2:
score: 0
Accepted
time: 1ms
memory: 3480kb
input:
2 0
output:
? 10 ! 0
result:
ok Correct answer with 1 queries.
Test #3:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
4 1 3 2 2 2 1 1 2 0 0
output:
? 1000 ? 0100 ? 1100 ? 1100 ? 0010 ? 1110 ? 1110 ? 0001 ? 1111 ? 1111 ! 1
result:
ok Correct answer with 10 queries.
Test #4:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
2 0
output:
? 10 ! 0
result:
ok Correct answer with 1 queries.
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 3524kb
input:
50 3 14 15 13 16 7 10 2 5 1 4 4 15 15 18 18 9 11 4 8 4 8 8 15 15 18 20 15 18 9 16 4 12 12 15 14 14 18 6 16 1 12 12 15 14 13 18 5 16 1 13 13 15 14 13 18 5 16 1 13 13 16 14 12 18 4 16 16 17 14 10 18 5 18 3 17 17 16 14 7 18 2 18 1 17 17 17 14 7 18 1 18 18 17 14 6 18 2 19 19 18 14 6 18 3 18 18 18 14 3 1...
output:
? 10000000000000000000000000000000000000000000000000 ? 01111111111111111111111110000000000000000000000000 ? 11111111111111111111111110000000000000000000000000 ? 01111111111100000000000000000000000000000000000000 ? 11111111111100000000000000000000000000000000000000 ? 011111000000000000000000000000000...
result:
wrong answer Wrong answer.