제출 #1233460

#제출 시각아이디문제언어결과실행 시간메모리
1233460hengliaoCOVID tests (CEOI24_covid)C++20
52.27 / 100
1936 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; } bool check(string s){ for(ll i=0;i<n;i++){ if(s[i]=='1') return true; } return false; } string f(ll lef, ll rig, bool exist){ string tep; for(ll i=0;i<n;i++){ if(i>=lef && i<=rig){ tep+='1'; } else{ tep+='0'; } } bool re; if(!exist) re=qry(tep); else re=1; 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, 0); bool dumb=0; if(!check(tep1)) dumb=1; string tep2=f(mid+1, rig, dumb); return mrg(tep1, tep2); } void solve(){ string s; for(ll i=0;i<n;i++) s+='1'; bool dumb=qry(s); if(!dumb){ s=""; for(ll i=0;i<n;i++) s+='0'; ans(s); return; } string a=f(0, n-1, 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...