Submission #964319

#TimeUsernameProblemLanguageResultExecution timeMemory
964319IUA_HasinCombo (IOI18_combo)C++17
5 / 100
1 ms500 KiB
#include "combo.h" #include <bits/stdc++.h> #define endl "\n" #define yeap cout<<"YES"<<endl #define nope cout<<"NO"<<endl #define ll long long using namespace std; // std::string guess_sequence(int N) { // std::string p = ""; // for (int i = 0; i < 4 * N; ++i) { // p += 'A'; // } // int coins = press(p); // std::string S = ""; // for (int i = 0; i < N; ++i) { // S += 'A'; // } // return S; // } std::string guess_sequence(int N) { std::string S = ""; ll first_char; std::string p1 = "AB"; std::string p2 = "A"; std::string p3 = "X"; ll a = press(p1); if(a>=1){ ll b = press(p2); if(b==1){ S += "A"; first_char = 1; } else { S += "B"; first_char = 2; } } else { ll b = press(p3); if(b==1){ S += "X"; first_char = 3; } else { S += "Y"; first_char = 4; } } // cout<<first_char<<endl;; ll cnt = 1; for(int i=3; i<=N; i++){ std::string temp_string = ""; std::string temp_string1 = ""; std::string temp_string2 = ""; std::string temp_string3 = ""; if(first_char==1){ temp_string1 += S; temp_string1 += "BB"; temp_string2 += S; temp_string2 += "BX"; temp_string3 += S; temp_string3 += "BY"; temp_string += S; temp_string += "X"; temp_string += temp_string1+temp_string2+temp_string3; ll aa = press(temp_string); if(aa==cnt+2){ S += "B"; cnt++; } else if(aa==cnt+1){ S += "X"; cnt++; } else { S += "Y"; cnt++; } } else if(first_char==2){ temp_string1 += S; temp_string1 += "AA"; temp_string2 += S; temp_string2 += "AX"; temp_string3 += S; temp_string3 += "AY"; temp_string += S; temp_string += "X"; temp_string += temp_string1+temp_string2+temp_string3; ll aa = press(temp_string); if(aa==cnt+2){ S += "A"; cnt++; } else if(aa==cnt+1){ S += "X"; cnt++; } else { S += "Y"; cnt++; } } else if(first_char==3){ temp_string1 += S; temp_string1 += "AA"; temp_string2 += S; temp_string2 += "AB"; temp_string3 += S; temp_string3 += "AY"; temp_string += S; temp_string += "Y"; temp_string += temp_string1+temp_string2+temp_string3; ll aa = press(temp_string); if(aa==cnt+2){ S += "A"; cnt++; } else if(aa==cnt+1){ S += "Y"; cnt++; } else { S += "B"; cnt++; } } else if(first_char==4){ temp_string1 += S; temp_string1 += "AA"; temp_string2 += S; temp_string2 += "AB"; temp_string3 += S; temp_string3 += "AX"; temp_string += S; temp_string += "X"; temp_string += temp_string1+temp_string2+temp_string3; ll aa = press(temp_string); if(aa==cnt+2){ S += "A"; cnt++; } else if(aa==cnt+1){ S += "X"; cnt++; } else { S += "B"; cnt++; } } } std::string last2 = ""; std::string last1 = ""; if(first_char==1){ last2 += S; last2 += "B"; last1 += last2; last1 += S; last1 += "Y"; last2 += S; last2 += "X"; ll aa = press(last2); ll bb = press(last1); if(aa==cnt){ S += "Y"; } else { if(bb==cnt){ S += "X"; } else { S += "B"; } } } else if(first_char==2){ last2 += S; last2 += "A"; last1 += last2; last1 += S; last1 += "Y"; last2 += S; last2 += "X"; ll aa = press(last2); ll bb = press(last1); if(aa==cnt){ S += "Y"; } else { if(bb==cnt){ S += "X"; } else { S += "A"; } } } else if(first_char==3){ last2 += S; last2 += "A"; last1 += last2; last1 += S; last1 += "Y"; last2 += S; last2 += "B"; ll aa = press(last2); ll bb = press(last1); if(aa==cnt){ S += "Y"; } else { if(bb==cnt){ S += "B"; } else { S += "A"; } } } else if(first_char==4){ last2 += S; last2 += "A"; last1 += last2; last1 += S; last1 += "B"; last2 += S; last2 += "X"; ll aa = press(last2); ll bb = press(last1); if(aa==cnt){ S += "B"; } else { if(bb==cnt){ S += "X"; } else { S += "A"; } } } // cout<<S<<endl; return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...