# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
450394 | MohamedAliSaidane | 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.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define pb push_back
#define popb pop_back
#define ff first
#define ss second
const int MOD = 1e9 + 7;
const int MAX_N = 5004;
bool visited[MAX_N];
void exploreCave(int n)
{
int comb[n];
memset(comb,0,sizeof(comb));
int first = tryCombination(comb);
vi ass(n,0);
vi state(n,0);
int cnt = 0;
while(cnt < n)
{
for(int i = 0; i < n ; i ++)
{
if(visited[i])
continue;
comb[i] = 1 - comb[i];
int ess = tryCombination(comb);
if(ess != -1 && ess < first)
{
comb[i] = 1 - comb[i];
ass[i] = ess;
state[i] = comb[i];
visited[i] = true;
cnt ++;
}
else if(ess > first)
{
ass[i] = first;
state[i] = comb[i];
visited[i] = true;
first = ess;
cnt ++;
}
}
}
answer(state,ass);
return ;
}