Submission #1302862

#TimeUsernameProblemLanguageResultExecution timeMemory
1302862antarbanikCombo (IOI18_combo)C++20
0 / 100
1 ms332 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; /* A B X Y -> ei 4 ta button ache game er ekta secret sequence of buttons ache -> s s oi ta button diya toiri S er first character ta abar reappears hoy na S, P press() function ta return korbo longest prefix of S that is also a substr of P */ // p: seq of buttons that i press. // len of p [0,4N] // 8000 bar er besi ei function ta call kora jaito na // amare oi string ta implement kora lagbo // N = len of string S string guess_sequence(int N){ string ans; bool f = 0; for(int i = 0; i < 26; ++i){ char c = 'a' + i; if(c != 'a' && c != 'b' && c != 'x' && c != 'y') continue; if(press(string(1, c)) == 1){ ans.push_back(c); f = 1; break; } } if(!f) return ans; f = 0; for(int i = 0; i < 26; ++i){ char c = 'a' + i; if(c != 'a' && c != 'b' && c != 'x' && c != 'y') continue; if(c == ans[0]) continue; if(press(ans + c) == 2){ ans.push_back(c); f = 1; break; } } if(!f) return ans; f = 0; for(int i = 0; i < 26; ++i){ char c = 'a' + i; if(c != 'a' && c != 'b' && c != 'x' && c != 'y') continue; if(c == ans[0]) continue; if(press(ans + c) == 3){ ans.push_back(c); break; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...