#include<iostream>
#include<algorithm>
#include<vector>
#include<random>
#include<ctime>
using namespace std;
using lint = long long;
using intp = pair<int,int>;
using vint = vector<int>;
const int MAX_N=1010;
int n,q;
double p;
int sf[MAX_N];
char ask[MAX_N];
char ans[MAX_N];
int askq()
{
int a;
cout << "Q " << ask << endl;
cin >> a;
return a;
}
void calc(int s,int e)
{
vint v;
for(int i=s;i<e;i++)
if(ans[sf[i]]=='0')
v.push_back(sf[i]);
for(auto x : v)ask[x]='1';
int a=askq();
for(auto x : v)ask[x]='0';
if(!a)
return;
int lb=0,ub=v.size()-1;
while(lb<ub)
{
int m=(lb+ub)/2;
for(int i=lb;i<=m;i++)ask[v[i]]='1';
int a=askq();
for(int i=lb;i<=m;i++)ask[v[i]]='0';
if(a)ub=m;
else lb=m+1;
}
ans[v[lb]]='1';
calc(s,e);
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin >> n >> q >> p;
fill(ask,ask+n,'0');
fill(ans,ans+n,'0');
if(q==1)
{
for(int i=0;i<n;i++)
{
ask[i]='1';
ans[i]='0'+askq();
ask[i]='0';
}
char c;
cout << "A " << ans << endl;
cin >> c;
return 0;
}
srand(time(NULL));
for(int i=0;i<n;i++)
sf[i]=i;
for(int i=0;i<n;i++)
swap(sf[i],sf[i+(rand()%(n-i))]);
int chunk=1/p;
while(q--)
{
fill(ans,ans+n,'0');
for(int i=0;i<n;i+=chunk)
calc(i,min(n,i+chunk));
char c;
cout << "A " << ans << endl;
cin >> c;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Unexpected end of file - token expected |
2 |
Halted |
0 ms |
0 KB |
- |