| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1310690 | theiulius | Cave (IOI13_cave) | C++20 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define pb push_back
// #include "graderlib.c"
// #include "cave.h"
int t = 1;
int n = 0;
// void answer(int a[], int b[]){
// for (int i = 0; i < n; i++){
// cout << a[i] << " ";
// }
// cout << endl;
// for (int i = 0; i < n; i++){
// cout << b[i] << " ";
// }
// cout << endl;
// }
// int tryCombination(int s[]){
// for (int i = 0; i < n; i++){
// cout << s[i] << " ";
// }
// cout << endl;
// int x;
// cin >> x;
// return x;
// }
void exploreCave(int N) {
n = N;
int a[n] = {}, b[n] = {};
for (int i = 0; i < n; i++){ // doors
int x = tryCombination(a);
if (x > i || x == -1){ // gagebulia i
a[i] = 0;
}else{
a[i] = 1; // kari 1-ze igeba
}
int l = i, r = n - 1, ans = i;
while (l <= r){
int mid = (l + r) / 2;
for (int j = i; j <= mid; j++){
a[j] = b[i];
}
for (int j = mid + 1; j < n; j++){
a[j] = 1 ^ b[i];
}
x = tryCombination(a);
if (x > i || x == -1){
r = mid - 1;
ans = mid;
}else{
l = mid + 1;
}
}
b[ans] = i;
}
answer(a, b);
}
// main(){
// exploreCave(4);
// }
