Submission #1097387

#TimeUsernameProblemLanguageResultExecution timeMemory
1097387LCJLYCombo (IOI18_combo)C++14
100 / 100
27 ms1312 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; //void press(p); string guess_sequence(int N) { //first letter guess char first; int hold= press("AB"); if(hold>=1){ hold=press("A"); if(hold==1){ first='A'; } else{ first='B'; } } else{ hold=press("X"); if(hold==1){ first='X'; } else{ first='Y'; } } unordered_map<string,string>mp; unordered_map<char,char>mp2; if(first=='A'){ mp["AB"]="XY"; mp["AX"]="XX"; mp["AY"]="XB"; mp["B"]='B'; mp2['A']='X'; mp2['B']='B'; mp2['X']='Y'; } else if(first=='B'){ mp["AB"]="XY"; mp["AX"]="XA"; mp["AY"]="XX"; mp["B"]='A'; mp2['A']='X'; mp2['B']='A'; mp2['X']='Y'; } else if(first=='X'){ mp["AB"]="AB"; mp["AX"]="AY"; mp["AY"]="AA"; mp["B"]='B'; mp2['A']='A'; mp2['B']='B'; mp2['X']='Y'; } else{ //Y mp["AB"]="AB"; mp["AX"]="AX"; mp["AY"]="AA"; mp["B"]='B'; mp2['A']='A'; mp2['B']='B'; mp2['X']='X'; } //normal guess string ans=""; ans.push_back(first); for(int x=1;x<N-1;x++){ hold=press(ans+mp["AB"]+ans+mp["AX"]+ans+mp["AY"]+ans+mp["B"]); if(hold==x+2){ ans.push_back(mp2['A']); } else if(hold==x+1){ ans.push_back(mp2['B']); } else{ ans.push_back(mp2['X']); } } //last guess if(N>1){ hold=press(ans+"A"+ans+"B"); if(hold==N){ hold=press(ans+"A"); if(hold==N){ ans.push_back('A'); } else{ ans.push_back('B'); } } else{ hold=press(ans+"X"); if(hold==N){ ans.push_back('X'); } else{ ans.push_back('Y'); } } } //cout << ans << " guess\n"; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...