#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "../Library/debug.h"
#else
#define dbg(x...)
#endif
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) for (int i = 0; i < (a); ++i)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); --i)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; --i)
#define trav(a, x) for (auto& a : x)
#define f first
#define s second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
const char nl = '\n';
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n;
double p;
vector<bool> ans;
bool ask(int l, int r){
cout<<"Q ";
string s(n,'0');
FOR(i,l,r+1)
s[i]='1';
cout<<s;
cout<<endl;
char ans;
cin>>ans;
return ans=='P';
}
void f(int l, int r){
int m=(l+r)/2;
bool b1=ask(l,m);
dbg(l,r,m,b1)
if(b1&&l==m){
ans[l]=1;
}
else if(b1&&l!=m){
f(l,m);
}
else if(!b1&&r==m+1){
ans[r]=1;
return;
}
else{
f(m+1,r);
return;
}
bool b2=ask(m+1,r);
dbg(b2)
if(b2&&m+1==r){
ans[r]=1;
}
else if(b2){
f(m+1,r);
}
}
void solve(){
f(0,n-1);
cout<<"A ";
F0R(i,n)
cout<<ans[i];
cout<<endl;
char c;
cin>>c;
}
int32_t main(){
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int TC = 1;
// cin >> TC;
cin>>n>>p>>TC;
while(TC--){
ans.resize(n);
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
translate:wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
336 KB |
Output is correct |
2 |
Correct |
12 ms |
336 KB |
Output is correct |
3 |
Correct |
14 ms |
336 KB |
Output is correct |
4 |
Correct |
16 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
336 KB |
Output is correct |
6 |
Correct |
13 ms |
336 KB |
Output is correct |
7 |
Correct |
12 ms |
336 KB |
Output is correct |
8 |
Correct |
8 ms |
336 KB |
Output is correct |
9 |
Correct |
11 ms |
336 KB |
Output is correct |
10 |
Correct |
8 ms |
336 KB |
Output is correct |
11 |
Correct |
10 ms |
336 KB |
Output is correct |
12 |
Correct |
14 ms |
336 KB |
Output is correct |
13 |
Correct |
13 ms |
336 KB |
Output is correct |
14 |
Correct |
11 ms |
336 KB |
Output is correct |
15 |
Correct |
12 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
336 KB |
Output is correct |
17 |
Incorrect |
1 ms |
336 KB |
translate:wrong |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
500 KB |
Execution killed with signal 13 |
2 |
Halted |
0 ms |
0 KB |
- |