# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
788606 | aykhn | 콤보 (IOI18_combo) | C++14 | 24 ms | 452 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 <bits/stdc++.h>
#include "combo.h"
// author: aykhn
using namespace std;
typedef long long ll;
#define TC int t; cin >> t; while (t--) _();
#define OPT ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define mpr make_pair
#define eb emplace_back
#define new int32_t
#define pb push_back
#define ts to_string
#define fi first
#define se second
//#define int ll
#define ins insert
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
string guess_sequence(int n)
{
srand(time(0));
string ans = "A";
vector<int> ch;
ch.pb('A');
ch.pb('B');
ch.pb('X');
ch.pb('Y');
int found = 0;
int id = 0;
int counnnnt = 0;
for (int i = rand() % 4; counnnnt < 3; i = (i + 1) % 4, counnnnt++)
{
ans[0] = ch[i];
id = i;
found = press(ans);
if (found) break;
}
if (!found)
{
ans[0] = ch[(id + 1) % 4];
id = (id + 1) % 4;
}
if (n == 1) return ans;
counnnnt = 0;
found = 0;
for (int i = rand() % 4; counnnnt < 2; i = (i + 1) % 4, counnnnt++)
{
if (ch[i] == ans[0])
{
counnnnt--;
continue;
}
string nw = ans;
nw.pb(ch[i]);
id = i;
found = press(nw);
if (found == 2) break;
}
if (found < 2)
{
id = (id + 1) % 4;
if (ch[id] == ans[0]) id = (id + 1) % 4;
}
if (n == 2)
{
ans.pb(ch[id]);
return ans;
}
vector<int> tmp;
for (int i = 0; i < 4; i++)
{
if (ch[i] == ans[0]) continue;
tmp.pb(ch[i]);
if (i == id)
{
id = tmp.size();
id--;
id = -id;
}
}
id = -id;
ch = tmp;
char add, nxt;
add = ch[id];
nxt = ch[(id + 1) % 3];
int prev = 1;
while (ans.length() != n)
{
string nw = ans;
nw.pb(add);
nw.pb(nxt);
int x = press(nw);
if (x - prev == 1)
{
ans.pb(add);
prev = x;
}
else if (x - prev == 2)
{
ans.pb(add);
ans.pb(nxt);
id = (id + 1) % 3;
add = ch[id];
nxt = ch[(id + 1) % 3];
prev = x;
}
else
{
id = (id + 2) % 3;
add = ch[id];
nxt = ch[(id + 1) % 3];
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |