# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390698 | JimmyZJX | Combo (IOI18_combo) | C++14 | 1 ms | 456 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 <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cassert>
#include <tuple>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef vector<int> Vi;
typedef vector<bool> Vb;
typedef vector<vector<int>> Vii;
#define forR(i, n) for (int i = 0; i < (n); i++)
int press(string p);
string guess_sequence(int N) {
// step 1: first
char first;
if (press("AB") >= 1) {
if (press("A") == 1) first = 'A';
else first = 'B';
} else {
if (press("X") == 1) first = 'X';
else first = 'Y';
}
string s; s.append(1, first);
set<char> keyset{ 'A','B','X','Y' }; keyset.erase(first);
vector<char> ks(keyset.begin(), keyset.end());
for (int i = 1; i <= N - 2; i++) {
string q = s + ks[2] + ks[0] + s + ks[2] + ks[1] + s + ks[2] + ks[2] + s + ks[1];
int r = press(q) - s.size();
s.append(1, ks[r]);
}
if (s.size() < N) {
assert(s.size() == N - 1);
if (press(s + ks[0]) == N) return s + ks[0];
if (press(s + ks[1]) == N) return s + ks[1];
return s + ks[2];
}
}
#ifdef TEST_LOCAL
string ans = "ABXYY";
int press(string p) {
for (int i = ans.size(); i > 0; i--) {
if (p.find(ans.substr(0, i)) != string::npos) {
return i;
}
}
return 0;
}
int main() {
auto c = guess_sequence(ans.size());
return 0;
}
#endif
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |