-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIOI08p1.cpp
More file actions
35 lines (31 loc) · 950 Bytes
/
Copy pathIOI08p1.cpp
File metadata and controls
35 lines (31 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string ans;
int t = press("AB");
char first; string rest;
if (t >= 1) {
if (press("A") >= 1) { first = 'A'; rest = "BXY"; }
else { first = 'B'; rest = "AXY"; }
}
else {
if (press("X") >= 1) { first = 'X'; rest = "ABY"; }
else { first = 'Y'; rest = "ABX"; }
}
ans += first;
char B = rest[0], X = rest[1], Y = rest[2];
while ((int)ans.size() < N - 1) {
string q = ans + B + ans + X + B + ans + X + X + ans + X + Y;
int r = press(q);
if (r == (int)ans.size()) ans += Y;
else if (r == (int)ans.size() + 1) ans += B;
else ans += X;
}
if ((int)ans.size() < N) {
if (press(ans + B) == (int)ans.size() + 1) ans += B;
else if (press(ans + X) == (int)ans.size() + 1) ans += X;
else ans += Y;
}
return ans;
}