# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1031511 | ArthuroWich | 콤보 (IOI18_combo) | C++17 | 33 ms | 1512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
string s;
int v;
v = press("AB");
if (v == 2) {
s = "AB";
} else if (v == 1) {
v = press("A");
if (v == 1) {
s = "A";
} else {
s = "B";
}
} else {
v = press("XY");
if (v == 2) {
s = "XY";
} else {
v = press("X");
if (v == 1) {
s = "X";
} else {
s = "Y";
}
}
}
if (n == 1) {
return s;
} else if (s.length() == n) {
return s;
}
vector<string> alp;
for (char c : "ABXY") {
if (c != s[0]) {
string t = "";
t.push_back(c);
alp.push_back(t);
}
}
while(s.length() != n) {
int si = 0, a = 1;
while(((si+1+s.length())*3*a+1)/2 < 4*n) {
si++;
a *= 3;
}
si = min(si, n-(int)s.length());
vector<vector<string>> c(si);
c[0].push_back(s+alp[0]);
c[0].push_back(s+alp[1]);
c[0].push_back(s+alp[2]);
for (int i = 1; i < si; i++) {
for (string e : c[i-1]) {
c[i].push_back(e+alp[0]);
c[i].push_back(e+alp[1]);
c[i].push_back(e+alp[2]);
}
}
int ch = s.length()+si;
int l = 0, r = c[si-1].size()-1;
while(l < r) {
int m = (l+r)/2;
string s1 = "";
for (int i = m+1; i <= r; i++) {
s1 += c[si-1][i];
}
if (press(s1) != ch) {
r = m;
} else {
l = m+1;
}
}
v = s.length();
for (int i = v; i < c[si-1][l].length(); i++) {
s.push_back(c[si-1][l][i]);
}
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |