제출 #1367362

#제출 시각아이디문제언어결과실행 시간메모리
1367362gvancakCOVID tests (CEOI24_covid)C++20
63.42 / 100
3714 ms444 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
const ll N=505,INF=1e12;
ll x,n,t,ind,cur,pw[N];
char c;
string s,ans;
bool check(int l,int r){
	string ragac="";
	for (int i=0; i<n; i++) ragac+='0';
	for (int i=l; i<=r; i++) ragac[i]='1';
	cout<<"Q "<<ragac<<endl;
	cin >> c;
	if (c=='P') return 1;
	return 0; 
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    double p;
    cin >> n ;
    cin >> p;
    cin >> t;
 	ans="";
    for (int i=1; i<=n; i++) ans+='0';
    pw[0]=1;
    int bl=(int)(0.76/p),r;
    for (int i=1; i<=log2(n); i++) pw[i]=pw[i-1]*2;
    while (t--){
    	ind=0; 
    	while (ind<n){
    		r=min(ind+bl-1,n-1);
    		if (check(ind,r)==0){
    			ind=r+1; continue;
			}
			cur=ind;
			for (int o=log2(n); o>=0; o--){
				if (cur+pw[o]>=r) continue;
				cur+=pw[o];
				if (check(ind,cur)) cur-=pw[o];
			}
			if (cur==ind && (ind==n-1 || check(ind,ind)==1)) cur--;
			cur++;
			ans[cur]='1';
			ind=cur+1;
		}
		cout<<"A "<<ans<<endl;
		cin >> c;
		if (c=='W') return 0;
		for (int i=0; i<n; i++) ans[i]='0';
	}

}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…