| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1305919 | fafnir | 콤보 (IOI18_combo) | C++20 | 12 ms | 448 KiB |
#include <bits/stdc++.h>
#ifndef LOCAL
#include "combo.h"
#endif
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#ifdef LOCAL
int press(string s);
#endif
const int M = 4;
char ABC[] = "ABXY";
char REM[3];
string guess_sequence(int N) {
string s;
REP(i, M-1) {
if (press(s + ABC[i])) {s += ABC[i]; break;}
}
if (!s.length()) {s += ABC[M-1];}
{
int idx = 0;
REP(i, M) {
if (s[0] != ABC[i]) {REM[idx++] = ABC[i];}
}
}
REP(i, N-1) {
random_shuffle(REM, REM+1);
if (press(s + REM[0]) == (i+2)) {s += REM[0];}
else if (press(s + REM[1]) == (i+2)) {s += REM[1];}
else {s += REM[2];}
}
return s;
}
#ifdef LOCAL
string SECRET = "ABBBXBXBXBYYYYBBY";
int press(string p) {
const int m = p.length();
const int n = SECRET.length();
int lpref = 0;
REP(i, m) {
int j = 0;
while (j < n && i+j < m && SECRET[j] == p[i+j]) {j++;}
lpref = max(lpref, j);
}
return lpref;
}
int main() {
cout << guess_sequence(SECRET.length()) << '\n';
}
#endif
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
