Submission #522123

#TimeUsernameProblemLanguageResultExecution timeMemory
522123new_accCombo (IOI18_combo)C++14
100 / 100
35 ms536 KiB
#include<bits/stdc++.h> #include "combo.h" #define ll long long #define fi first #define se second using namespace std; const size_t N=2e3+10; string s; /*size_t press(string p){ size_t res=0; for(size_t i=0;i<p.size();i++){ size_t j=i; while(j-i<s.size()&&j<p.size()&&p[j]==s[j-i]) j++; res=max(res,j-i); } return res; }*/ string guess_sequence(int n){ string curr=""; string k1,k2,k3; int xd=press("AB"); if(xd>=1){ xd=press("B"); if(xd==1) curr+="B",k1="X",k2="Y",k3="A"; else curr+="A",k1="X",k2="Y",k3="B"; }else{ xd=press("X"); if(xd==1) curr+="X",k1="B",k2="Y",k3="A"; else curr+="Y",k1="X",k2="B",k3="A"; } size_t i; for(i=2;(int)i<=n-2;){ size_t x=press(curr+k1+k2+k3+curr+k1+k1+k3+curr+k2+k1+k3); if(x==0+curr.size()){curr+=k3,i++;continue;} if(x==1+curr.size()){ size_t x2=press(curr+k1+curr+k2+k2+k3+curr+k2+k3+k3+curr+k2+k2+k1); if(x2==curr.size()+1){curr+=k1+k3;i+=2;continue;} if(x2==curr.size()+2){ size_t x3=press(curr+k2+k3+k1); if(x3==curr.size()+1) curr+=k2+k2+k2; else{ if(x3==curr.size()+2) curr+=k2+k3+k2; else curr+=k2+k3+k1; } i+=3; continue; } size_t x3=press(curr+k2+k2+k3); if(x3==curr.size()+1) curr+=k2+k3+k3; else{ if(x3==curr.size()+2) curr+=k2+k2+k1; else curr+=k2+k2+k3; } i+=3; continue; } if(x==2+curr.size()){ size_t x2=press(curr+k2+k1+curr+k1+k2+k1+curr+k1+k2+k2); if(x2==curr.size()+1){ size_t x3=press(curr+k1+k1+k1); if(x3==curr.size()+2) curr+=k1+k1+k2; else curr+=k1+k1+k1; i+=3; continue; } if(x2==curr.size()+2){ size_t x3=press(curr+k2+k1+k1); if(x3==curr.size()+2) curr+=k2+k1+k2; else curr+=k2+k1+k1; }else{ size_t x3=press(curr+k1+k2+k1); if(x3==curr.size()+2) curr+=k1+k2+k2; else curr+=k1+k2+k1; } i+=3; continue; }else{ size_t x2=press(curr+k1+k2+k3); if(x2==curr.size()+3){curr+=k1+k2+k3;i+=3;continue;} x2=press(curr+k1+k1+k3); if(x2==curr.size()+3) curr+=k1+k1+k3; else curr+=k2+k1+k3; i+=3; continue; } } if((int)curr.size()==n-2){ size_t x=press(curr+k1+k2+curr+k2+k2); if(x==curr.size()) curr+=k3; else{ if(x==curr.size()+2){ size_t x2=press(curr+k1+k2); if(x2==curr.size()+2) curr+=k1+k2; else curr+=k2+k2; }else{ size_t x2=press(curr+k1+k1+curr+k2+k1); if(x2==curr.size()+2){ size_t x3=press(curr+k1+k1); if(x3==curr.size()+2) curr+=k1+k1; else curr+=k2+k1; }else{ size_t x3=press(curr+k1); if(x3==curr.size()+1) curr+=k1+k3; else curr+=k2+k3; } } } } if((int)curr.size()==n-1){ size_t x=press(curr+k1); if(x==curr.size()+1) curr+=k1; else{ x=press(curr+k2); if(x==curr.size()+1) curr+=k2; else curr+=k3; } } return curr; } /*int main(){ cin>>s; cout<<guess_sequence(s.size())<<"\n"; return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...