제출 #1233506

#제출 시각아이디문제언어결과실행 시간메모리
1233506hengliaoCOVID tests (CEOI24_covid)C++20
컴파일 에러
0 ms0 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; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll B; ll rand(ll a, ll b){ return rng()%(b-a+1)+a; } 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){ if(lef>rig){ string tep; for(ll i=0;i<n;i++){ tep+='0'; } return tep; } double stupid=(double) (rig-lef+1)*p; if(stupid<5){ vector<bool> v(n); auto ff=[&](ll tar){ string tep; for(ll i=0;i<n;i++){ if(i>=lef && i<=rig && i<=tar && !v[i]){ tep+='1'; } else{ tep+='0'; } } return qry(tep); }; ll pre=lef-1; while(pre<rig){ ll l=pre+1, r=rig; ll good=-1; while(l<=r){ ll mid=(l+r)/2; if(ff(mid)){ good=mid; r=mid-1; } else{ l=mid+1; } } if(good==-1) break; v[good]=1; pre=good; } string tep; for(ll i=0;i<n;i++){ if(v[i]) tep+='1'; else tep+='0'; } // ans(tep); return tep; } 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; } // if(rig-lef+1==2){ ll mid=(lef+rig)/2; if(rand(0, 1)==0){ 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); } else{ string tep2=f(mid+1, rig, 0); bool dumb=0; if(!check(tep2)) dumb=1; string tep1=f(lef, mid, dumb); return mrg(tep1, tep2); } // } // else{ // ll diff=(rig-lef)/3; // ll mid1=lef+diff; // ll mid2=rig-diff; // string tep1=f(lef, mid1, 0); // string tep2=f(mid1+1, mid2-1, 0); // bool dumb=0; // if(!check(tep1) && !check(tep2)) dumb=1; // string tep3=f(mid2, rig, dumb); // return mrg(mrg(tep1, tep2), tep3); // } } 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; for(ll i=0;i<n;i++){ a+='0'; } for(ll i=0;i<n;i+=B){ string tep; for(ll j=0;j<n;j++){ if(j-i>=0 && j-i<4) tep+='1'; else tep+='0'; } if(qry(tep)){ string tep2=f(i, min(i+3, n-1), 1); a=mrg(a, tep2); } } ans(a); } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>p>>t; B=round((double) 1/p) while(t--){ solve(); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:209:30: error: expected ';' before 'while'
  209 |         B=round((double) 1/p)
      |                              ^
      |                              ;
  210 | 
  211 |         while(t--){
      |         ~~~~~