| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1359013 | avahw | 콤보 (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
std::string s = "";
string ref = "ABXY";
int n = N;
// brute force first char
for(int i = 0; i < ref.size(); i++){
int coin = press(s + ref[i]);
if(coin == 1){ s += ref[i];
break; }
}
if(s.size() == 0) s += 'Y';
// only need to guess three other chars
string p = "";
for(auto e : ref) if(e != s[0]) p += e;
for(int i = 1; i < n - 1; i++){
string guess =
s + p[0] +
s + p[1] + p[0] +
s + p[1] + p[1] +
s + p[1] + p[2];
int coins = press(guess);
int gain = coins - i;
if(gain == 0){
s += p[2];
}
if(gain == 1){
s += p[0];
}
if(gain == 2){
s += p[1]
}
}
for(int i = 0; i < p.size(); i++){
int coin = press(s + p[i]);
if(coin == n){ s += p[i];
break; }
}
return s;
}
