제출 #393686

#제출 시각아이디문제언어결과실행 시간메모리
393686phathnv콤보 (IOI18_combo)C++11
100 / 100
42 ms572 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { char ch[4] = {'A', 'B', 'X', 'Y'}; int l = 0, r = 3; while (l < r){ int mid = (l + r) >> 1; string tmp; for(int i = l; i <= mid; i++) tmp.push_back(ch[i]); if (press(tmp) > 0) r = mid; else l = mid + 1; } swap(ch[3], ch[l]); string s; s.push_back(ch[3]); for(int i = 2; i < n; i++){ string tmp = s + ch[1] + s + ch[2] + ch[0] + s + ch[2] + ch[1] + s + ch[2] + ch[2]; s.push_back(ch[press(tmp) - i + 1]); } if ((int) s.size() == n) return s; if (press(s + ch[0]) == n) s.push_back(ch[0]); else if (press(s + ch[1]) == n) s.push_back(ch[1]); else s.push_back(ch[2]); return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...