# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
885823 | sq00 | 콤보 (IOI18_combo) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
string guess_sequence(int N) {
string buttons = "", firstBtn = "";
int aCost = press("AX");
if(aCost == 2) {
firstBtn = "A";
buttons = "BYX";
} else if(aCost == 1) {
aCost = press("A");
if(aCost == 1) {
firstBtn = "A";
buttons = "BYX";
} else {
firstBtn = "X";
buttons = "ABY";
}
} else {
int bCost = press("BY");
if(bCost == 2) {
firstBtn = "B";
buttons = "AYX";
} else {
aCost = press("B");
if(aCost == 1) {
firstBtn = "B";
buttons = "AYX";
} else {
firstBtn = "Y";
buttons = "ABX";
}
}
}
string current = firstBtn;
if(current.size() == N) return current;
while(true) {
for(int i = 0; i < (int)buttons.size(); i++) {
string test = current + buttons[i];
if(test.size() < N) {
for(int j = 0; j < (int)buttons.size(); j++) {
test += current + buttons[i + 1] + buttons[j];
}
}
int cost = press(test);
if(cost == current.size() + 1) {
current += buttons[i];
break;
} else if(cost == current.size() + 2) {
current += buttons[i + 1];
break;
} else if(current.size() + 1 < N) {
current += buttons[i + 2];
break;
}
if(i == 1) {
current += buttons[2];
break;
}
}
if(current.size() == N) break;
}
return current;
}