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 "cave.h"
using namespace std;
void exploreCave(int N) {
int combination[N];
memset(combination, false, sizeof(combination));
bool found[N];
memset(found, false, sizeof(found));
int connection[N];
memset(connection, 0, sizeof(connection));
bool foundswitch[N];
memset(foundswitch, 0, sizeof(foundswitch));
int n = N;
for(int i=0;i<N;i++) {
int st = tryCombination(combination);
if(st == -1) st = n;
for(int j=0;j<N;j++) {
if(found[j]) continue;
combination[j] = true;
int x = tryCombination(combination);
if(x == -1) x = n;
combination[j] = false;
//cout<<j<<" - "<<x<<" and "<<st<<"\n";
if(x == st) continue;
else if(x < st && !foundswitch[x]) {
// we have closed the x'th door
found[j] = true;
combination[j] = false;
connection[j] = x;
foundswitch[x] = true;
}
else if(x > st && !foundswitch[st]) {
found[j] = true;
combination[j] = true;
connection[j] = st;
foundswitch[st] = true;
// we have opened the st'th door
}
}
}
answer(combination, connection);
}
# | 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... |