# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
229940 | kartel | 콤보 (IOI18_combo) | C++14 | 42 ms | 556 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 "grader.cpp"
#include "combo.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-O3")
#define F first
#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e18)
#define el '\n'
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
string guess_sequence(int n)
{
string s = "";
int len;
int I, x, X, i, k, p, j, L, l, mk[2][5] {0};
srand(time(0));
char c[4] = {'A', 'B', 'X', 'Y'};
random_shuffle(c, c + 4);
for (i = 0; i < 4; i++)
{
s = "";
s += c[i];
p = press(s);
if (p == 1) break;
}
I = i;
len = 2;
x = 0;
while (len <= n)
{
x ^= 1;
for (i = 0; i < 4; i++) mk[x][i] = 0;
j = rand() % 3 + 1;
l = 0;
while (l < 4 && j > 0)
{
if (l == I) {l++;continue;}
if (!mk[x][l]) j--;
if (j == 0) break;
l++;
}
// for (i = 0; i < 4; i++) cerr << mk[x][i] << " ";
// cerr << el;
// cerr << len << " " << c[l] << " " << s << el;
s += c[l];
p = press(s);
if (p == s.size()) {len++;continue;}
if (p == sz(s) - 2)
{
int y = x ^ 1;
i = 0;
while (i < 4)
{
if (i == I) {i++;continue;}
if (!mk[y][i]) break;
i++;
}
s[sz(s) - 2] = c[i];
p = press(s);
if (p == sz(s)) {len++;continue;}
if (p < sz(s) - 1) assert(0 > 1);
}
s.erase(sz(s) - 1);
mk[x][l] = 1;
j = rand() % 2 + 1;
l = 0;
while (l < 4 && j > 0)
{
if (I == l) {l++;continue;}
if (!mk[x][l]) j--;
if (j == 0) break;
l++;
}
s += c[l];
mk[x][l] = 1;
len++;
}
if (len > 1)
{
p = press(s);
if (p != sz(s))
{
int y = x;
i = 0;
while (i < 4)
{
if (i == I) {i++;continue;}
if (!mk[y][i]) break;
i++;
}
s[sz(s) - 1] = c[i];
}
}
return s;
}
//int main()
//{
// srand(time(0));
// ios_base::sync_with_stdio(0);
// iostream::sync_with_stdio(0);
// ios::sync_with_stdio(0);
// cin.tie(NULL);
// cout.tie(NULL);
//
//// in("input.txt");
//// out("output.txt");
//
//
//}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |