제출 #393652

#제출 시각아이디문제언어결과실행 시간메모리
393652phathnvCombo (IOI18_combo)C++11
0 / 100
37 ms204 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { string s; 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[0], ch[l]); for(int t = 1; t <= 2; t++){ s.push_back(ch[0]); for(int i = 2; i <= n; i++) s.push_back(ch[t]); } int lastPress = press(s); for(int i = 2; i <= n; i++){ if (lastPress < i){ s[i - 1] = s[i + n - 1] = ch[3]; lastPress = press(s); } else { s[i + n - 1] = ch[1]; int tmp = press(s); if (tmp < lastPress) s[i - 1] = s[i + n - 1] = ch[2]; else lastPress = tmp; } } return s.substr(0, n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...