# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123558 | johutha | Cave (IOI13_cave) | C++14 | 0 ms | 0 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.
#ifdef _WIN32
#include "cave.h"
#else
#include "grader.h"
#endif
#include <vector>
#include <iostream>
using namespace std;
int n;
vector<int> perms;
vector<int> combsol;
int ask(vector<int> out)
{
vector<int> tos(n);
for (int i = 0; i < n; i++)
{
if (perms[i] != -1)
{
tos[i] = combsol[i];
}
else
{
tos[i] = out[i];
}
}
int r = tryCombination(tos.data());
return r;
}
int ask0()
{
vector<int> tos(n);
for (int i = 0; i < n; i++)
{
if (perms[i] != -1)
{
tos[i] = combsol[i];
}
else
{
tos[i] = 0;
}
}
int r = tryCombination(tos.data());
return r;
}
void exploreCave(int in)
{
n = in;
perms.resize(n, -1);
combsol.resize(n, -1);
int l2 = 13;
for (int i = 0; i < n; i++)
{
int resp = 0;
bool inv = (ask0() != i);
int up = 1;
for (int j = 0; j < l2; j++)
{
vector<int> out(n);
for (int k = 0; k < n; k++)
{
out[k] = inv ^ ((k / up) % 2);
}
int r = ask(out);
if (r != i) resp += up;
up *= 2;
}
perms[resp] = i;
combsol[resp] = !inv;
}
answer(combsol.data(), perms.data());
}