제출 #484871

#제출 시각아이디문제언어결과실행 시간메모리
484871MohamedFaresNebili콤보 (IOI18_combo)C++14
100 / 100
46 ms9824 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("Ofast") #pragma GCC target ("avx2") #include "combo.h" using namespace std; using ll = long long; using vi = vector<int>; #define pb push_back #define ff first #define ss second #define lb lower_bound #define all(x) (x).begin() , (x).end() string p = "", lett = "ABXY"; int n; void solve(int i, int first) { if(i == n) return; if(i == n - 1) { p+="x"; for(int l = 0; l < 2; l++) { if(l == first) continue; p[i] = lett[l]; if(press(p) == n) return; } if(first == 2) { p[i] = lett[3]; return; } else if(first == 3) { p[i] = lett[2]; return; } else { p[i] = lett[2]; if(press(p) == n) return; p[i] = lett[3]; return; } return; } vector<char>ch; for(int l = 0; l < 4; l++) { if(l == first) continue; ch.pb(lett[l]); } string s = ""; for(auto u: ch) s+=p+ch[0]+u; s += p; s+=ch[1]; p+="x"; int u = press(s); if(u == i + 1) p[i] = ch[1]; else if(u >= i + 2) p[i] = ch[0]; else p[i] = ch[2]; solve(i+1, first); } string guess_sequence(int N) { int first = -1; n = N; string s = "AB"; int u = press(s); if(u >= 1) { s = "A"; if(press(s)) first = 0; else first = 1; } else { s = "X"; if(press(s)) first = 2; else first = 3; } p = lett[first]; solve(1, first); return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...