#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
const char nl = '\n';
void fastIO() {
ios::sync_with_stdio(false);
cin.tie(0);
}
int N, T;
double P;
char query(vi v) {
string s(N, '0');
for (int x : v)
s[x] = '1';
cout<<"Q "<<s<<endl;
cout.flush();
char c;
cin>>c;
return c;
}
char query(int l, int r) {
string s(N, '0');
for (int i = l; i <= r; i++) {
s[i] = '1';
}
cout<<"Q "<<s<<endl;
cout.flush();
char c;
cin>>c;
return c;
}
string ans(N, '0');
void solve(int left, int right) { // know there's positive on range
if (left > right)
return;
else if (left == right) {
ans[left] = '1';
return;
}
int mid = (left + right) / 2;
if (query(left, mid) == 'P') {
solve(left, mid);
if (query(mid + 1, right) == 'P')
solve(mid + 1, right);
}
else {
solve(mid + 1, right);
}
}
int main() {
fastIO();
cin>>N>>P>>T;
for (int i = 0; i < T; i++) {
ans = string(N, '0');
if (query(0, N - 1))
solve(0, N - 1);
// cout<<"ANSWER: ";
cout<<"A "<<ans<<endl;
cout.flush();
char c;
cin>>c;
if (c == 'W')
break;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
344 KB |
Output is correct |
2 |
Correct |
11 ms |
344 KB |
Output is correct |
3 |
Correct |
9 ms |
344 KB |
Output is correct |
4 |
Correct |
8 ms |
344 KB |
Output is correct |
5 |
Correct |
9 ms |
344 KB |
Output is correct |
6 |
Correct |
11 ms |
344 KB |
Output is correct |
7 |
Correct |
7 ms |
344 KB |
Output is correct |
8 |
Correct |
7 ms |
344 KB |
Output is correct |
9 |
Correct |
7 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
344 KB |
Output is correct |
12 |
Correct |
7 ms |
340 KB |
Output is correct |
13 |
Correct |
10 ms |
344 KB |
Output is correct |
14 |
Correct |
7 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
344 KB |
Output is correct |
16 |
Correct |
11 ms |
344 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
translate:wrong |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
translate:wrong |
2 |
Halted |
0 ms |
0 KB |
- |