Submission #116937

#TimeUsernameProblemLanguageResultExecution timeMemory
116937pzdbaCombo (IOI18_combo)C++14
100 / 100
54 ms576 KiB
#include <bits/stdc++.h> using namespace std; string s[4] = {"A", "B", "X", "Y"}, t[4]; int press(string s); string guess_sequence(int n){ if(n == 1){ int p = press(s[0] + s[1]); if(p == 1){ p = press(s[0]); if(p == 1) return s[0]; else return s[1]; } else{ p = press(s[2]); if(p == 1) return s[2]; else return s[3]; } } else{ string ans = ""; int p = press(s[0] + s[1]); if(p == 0){ p = press(s[2]); if(p == 1) ans += s[2]; else ans += s[3]; } else if(p == 1){ p = press(s[0]); if(p == 1) ans += s[0]; else ans += s[1]; } else ans += s[0]; int j = 0; for(int i=0;i<4;i++){ if(ans[0] != s[i][0]) t[j++] = s[i]; } int res = 1; for(int i=1;i<n;i++){ if(i == n-1){ p = press(ans + t[0] + ans + t[1]); if(p == res){ ans += t[2]; } else{ p = press(ans + t[0]); if(p == res+1) ans += t[0]; else ans += t[1]; } } else{ p = press(ans+t[0] + ans+t[1]+t[0] + ans+t[1]+t[1] + ans+t[1]+t[2]); if(p == res+0) ans += t[2]; else if(p == res+2) ans += t[1]; else ans += t[0]; res++; } } return ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...