QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#827842 | #9783. Duloc Network | Zawos | WA | 1ms | 3524kb | C++20 | 1.5kb | 2024-12-23 10:34:59 | 2024-12-23 10:34:59 |
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;
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++;
}
int fB = ask(query), fAB = fA + ask(OR(A, query));
if (!fB) return cout << "! 0" << endl, 0;
if (!cnt || 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;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3524kb
input:
4 1 3 2 0 1
output:
? 1000 ? 0100 ? 1100 ? 0000 ? 1000 ! 0
result:
wrong answer Wrong answer.