Submission #423556

#TimeUsernameProblemLanguageResultExecution timeMemory
423556PbezzCombo (IOI18_combo)C++14
0 / 100
1 ms256 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back typedef pair<ll,ll> pii; const ll MAXN = 2e5+5; const ll INF = 1e9+7; ll n; char st; string complete(string s){ //encher de st while((ll)s.size()!=n){ s.push_back(st); } return s; } std::string guess_sequence(int N) { n=N; string p,p1,p2,p3,p4; ll i,k; if(press("A")==1){ st='A'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); for(i=1;i<n-1;i++){//cout<<i<<"\n"; p1[i]='B'; p1[i+1]='B'; p2[i]='B'; p2[i+1]='X'; p3[i]='B'; p3[i+1]='Y'; p4[i]='X'; p4[i+1]='A'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); //cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "; p=p1+p2+p3+p4; k = press(p);//cout<<k<<endl; if(k==i){ p1[i]='Y'; p2[i]='Y'; p3[i]='Y'; p4[i]='Y'; }else if(k==i+1){ p1[i]='X'; p2[i]='X'; p3[i]='X'; p4[i]='X'; }else{ p1[i]='B'; p2[i]='B'; p3[i]='B'; p4[i]='B'; } } p1[n-1]='B'; if(press(p1)==n)return p1; p1[n-1]='X'; if(press(p1)==n)return p1; p1[n-1]='Y'; return p1; }else if(press("B")==1){ st='B'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); for(i=1;i<n-1;i++){//cout<<i<<"\n"; p1[i]='A'; p1[i+1]='A'; p2[i]='A'; p2[i+1]='X'; p3[i]='A'; p3[i+1]='Y'; p4[i]='X'; p4[i+1]='B'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); //cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "; p=p1+p2+p3+p4; k = press(p);//cout<<k<<endl; if(k==i){ p1[i]='Y'; p2[i]='Y'; p3[i]='Y'; p4[i]='Y'; }else if(k==i+1){ p1[i]='X'; p2[i]='X'; p3[i]='X'; p4[i]='X'; }else{ p1[i]='A'; p2[i]='A'; p3[i]='A'; p4[i]='A'; } } p1[n-1]='A'; if(press(p1)==n)return p1; p1[n-1]='X'; if(press(p1)==n)return p1; p1[n-1]='Y'; return p1; }else if(press("X")==1){ st='X'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); for(i=1;i<n-1;i++){//cout<<i<<"\n"; p1[i]='B'; p1[i+1]='B'; p2[i]='B'; p2[i+1]='A'; p3[i]='B'; p3[i+1]='Y'; p4[i]='A'; p4[i+1]='X'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); //cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "; p=p1+p2+p3+p4; k = press(p);cout<<k<<endl; if(k==i){ p1[i]='Y'; p2[i]='Y'; p3[i]='Y'; p4[i]='Y'; }else if(k==i+1){ p1[i]='A'; p2[i]='A'; p3[i]='A'; p4[i]='A'; }else{ p1[i]='B'; p2[i]='B'; p3[i]='B'; p4[i]='B'; } } p1[n-1]='B'; if(press(p1)==n)return p1; p1[n-1]='A'; if(press(p1)==n)return p1; p1[n-1]='Y'; return p1; }else{ st='Y'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); for(i=1;i<n-1;i++){//cout<<i<<"\n"; p1[i]='B'; p1[i+1]='B'; p2[i]='B'; p2[i+1]='X'; p3[i]='B'; p3[i+1]='A'; p4[i]='X'; p4[i+1]='Y'; p1=complete(p1); p2=complete(p2); p3=complete(p3); p4=complete(p4); //cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<" "; p=p1+p2+p3+p4; k = press(p);cout<<k<<endl; if(k==i){ p1[i]='A'; p2[i]='A'; p3[i]='A'; p4[i]='A'; }else if(k==i+1){ p1[i]='X'; p2[i]='X'; p3[i]='X'; p4[i]='X'; }else{ p1[i]='B'; p2[i]='B'; p3[i]='B'; p4[i]='B'; } } p1[n-1]='B'; if(press(p1)==n)return p1; p1[n-1]='X'; if(press(p1)==n)return p1; p1[n-1]='A'; return p1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...