# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962684 | serkanrashid | Cave (IOI13_cave) | C++14 | 245 ms | 852 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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int *s,*d;
int tekdoor;
int rec(vector<int>pos)
{
if(pos.size()==1) return pos[0];
int mid = (pos.size()-1)/2;
for(int j = 0; j <= mid; j++) s[pos[j]] ^= 1;
int ch = tryCombination(s);
vector<int>nb;
if(ch == tekdoor)
{
for(int j = mid+1; j < pos.size(); j++) nb.push_back(pos[j]);
return rec(nb);
}
for(int j = 0; j <= mid; j++)
{
s[pos[j]] ^= 1;
nb.push_back(pos[j]);
}
return rec(nb);
}
void exploreCave(int N)
{
int ch;
s = new int[N];
d = new int[N];
for(int i = 0; i < N; i++) d[i] = -1;
for(int i = 0; i < N; i++)
{
vector<int>pos;
for(int j = 0; j < N; j++)
{
if(d[j] == -1)
{
s[j] = 0;
pos.push_back(j);
}
}
ch = tryCombination(s);
if(ch != i)
{
for(int j = 0; j < N; j++) if(d[j] == -1) s[j] = 1;
}
tekdoor = i;
int idx = rec(pos);
d[idx] = i;
s[idx] ^= 1;
}
answer(s,d);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |