Submission #1233399

#TimeUsernameProblemLanguageResultExecution timeMemory
1233399hengliaoCOVID tests (CEOI24_covid)C++20
36.95 / 100
2207 ms476 KiB
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pll pair<ll, ll>
#define vll vector<ll>
#define pb push_back

typedef long long ll;

ll n, t;
double p;

bool qry(string s){
	cout<<"Q "<<s<<endl;
	char re;
	cin>>re;
	if(re=='P') return true;
	return false;
}

void ans(string s){
	cout<<"A "<<s<<endl;
	char re;
	cin>>re;
}

string mrg(string a, string b){
	string re;
	for(ll i=0;i<n;i++){
		if(a[i]=='1' || b[i]=='1') re+='1';
		else re+='0';
	}
	return re;
}

string f(ll lef, ll rig){
	string tep;
	for(ll i=0;i<n;i++){
		if(i>=lef && i<=rig){
			tep+='1';
		}
		else{
			tep+='0';
		}
	}
	bool re=qry(tep);
	if(!re){
		string tep;
		for(ll i=0;i<n;i++){
			tep+='0';
		}
		return tep;
	}
	if(lef==rig){
		string tep;
		for(ll i=0;i<n;i++){
			if(i==lef) tep+='1';
			else tep+='0';
		}
		return tep;
	}
	ll mid=(lef+rig)/2;
	string tep1=f(lef, mid);
	string tep2=f(mid+1, rig);
	return mrg(tep1, tep2);
}

void solve(){
	string a=f(0, n-1);
	ans(a);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	cin>>n>>p>>t;

	while(t--){
		solve();
	}

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...