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;
void answer(int S[], int D[]);
int tryCombination(int S[]);
void exploreCave(int N){
int ans[N], d[N];
memset(ans, 0, sizeof(ans));
memset(d, -1, sizeof(d));
vector<int> mn(N, 0);
int res = tryCombination(ans);
while(res != -1){
for(int j = 0; j < N; j++){
if(d[j] != -1 || mn[j] > res){
continue;
}
ans[j] ^= 1;
int res2 = tryCombination(ans);
if(res2 == -1 || res2 > res){
d[j] = res;
res = res2;
break;
} else{
mn[j] = max(mn[j], res);
ans[j] ^= 1;
continue;
}
}
if(res == -1){
for(int i = 0; i < N; i++){
if(d[i] == -1){
ans[i] ^= 1;
res = tryCombination(ans);
break;
}
}
}
}
for(int i = 0; i < N; i++){
if(d[i] == -1){
ans[i] ^= 1;
d[i] = tryCombination(ans);
ans[i] ^= 1;
}
}
answer(ans, d);
}
# | 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... |