#include "cave.h"
#include <complex.h>
#include <iostream>
#include <mutex>
#include <vector>
using namespace std;
void exploreCave(int N) {
vector <int> ans (N + 1);
vector <int> ans1 (N + 1);
vector <bool> locked (N + 1);
for (int i = 0; i < N; i++) {
int curres = tryCombination (ans.data());
if (curres == i) {
// try to find correct one
[&]()->void {
for (int j = 0; j < N; j++)
if (locked[j] == 0) {
ans[j] = 1;
unsigned int getres = tryCombination (ans.data());
if (getres > i) {
locked[j] = 1;
ans1[j] = i;
return;
} else
ans[j] = 0;
}
}();
} else {
// try to find incorrect one
for (int j = 0; j < N; j++)
if (locked[j] == 0) {
ans[j] = 1;
unsigned int getres = tryCombination (ans.data());
if (getres == i) {
locked[j] = 1;
ans[j] = 0;
ans1[j] = i;
break;
} else
ans[j] = 0;
}
}
}
answer (ans.data(), ans1.data());
}
# | 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... |