# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1012871 | rythm_of_knight | Combo (IOI18_combo) | C++14 | 6 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int n) {
string print;
int x;
char c;
vector <string> a(n, "ABXY");
string ans(n, 'C'), pos = "ABXY";
string tayyor;
x = press("AB");
if (x) {
x = press("A");
if (x)
c = 'A';
else
c = 'B';
} else {
x = press("X");
if (x)
c = 'X';
else
c = 'Y';
}
tayyor.push_back(c);
a[0] = c;
for (int i = 1; i < n; i++)
a[i].erase(a[i].begin() + a[i].find(c));
for (int i = 1; i < n; i++) {
if (a[i].size() == 1) {
tayyor.push_back(a[i][0]);
continue;
}
string temp = a[i];
int j = i + 1;
for (; j < n && a[j].size() == 1; j++);
if (a[i].size() == 3) {
if (j != n) {
char c1 = a[j][0];
print = tayyor + temp[0] + c1 + tayyor + temp[1] + c1;
x = press(print);
if (x == tayyor.size()) {
a[i] = temp[2], tayyor.push_back(temp[2]);
} else if (x == tayyor.size() + 1) {
a[j].erase(a[j].begin() + a[j].find(c1));
a[i].erase(a[i].begin() + a[i].find(temp[2]));
i--;
} else {
a[i].erase(a[i].begin() + a[i].find(temp[2]));
a[j] = c1;
i--;
}
} else {
print = tayyor + temp[0] + tayyor + temp[1];
x = press(print);
if (x == tayyor.size()) {
a[i] = temp[2], tayyor.push_back(temp[2]);
} else {
a[i].erase(a[i].begin() + a[i].find(temp[2]));
i--;
}
}
} else {
if (j != n) {
char c1 = a[j][0];
print = tayyor + temp[0] + c1;
x = press(print);
if (x == tayyor.size()) {
a[i] = temp[1];
} else if (x == tayyor.size() + 1) {
a[j].erase(a[j].begin() + a[j].find(c1));
a[i] = temp[0];
} else {
a[i] = temp[0];
a[j] = c1;
}
} else {
print = tayyor + temp[0];
x = press(print);
if (x == tayyor.size()) {
a[i] = temp[1];
} else {
a[i] = temp[0];
}
}
tayyor.push_back(a[i][0]);
}
}
return tayyor;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |