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;
// int main(){
// return 0;
// }
void exploreCave(int n) {
int swiches[n], partners[n];
bool founded[n];
fill(founded, founded + n, false);
fill(partners, partners + n, -1);
for (int i = 0; i < n; i++) {
cin >> swiches[i];
}
for (int i = 0; i < n; i++) {
int l = 0, r = n - 1;
for (int j = 0; j < n; j++) {
if (founded[j] == false) {
swiches[j] = 0;
}
}
int status = tryCombination(swiches) < i;
while (l != r){
int mid = (l + r) / 2;
for (int j = l; j <= r; j++) {
if (founded[j] == true) continue;
if (j <= mid){
swiches[j] = status;
}
else{
swiches[j] = 1 - status;
}
}
if (tryCombination(swiches) < i){
l = mid + 1;
}
else r = mid;
}
founded[l] = true;
partners[i] = l;
}
answer(swiches, partners);
}
# | 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... |