# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
985315 | SzymonKrzywda | Cave (IOI13_cave) | C++17 | 0 ms | 0 KiB |
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;
int tryCombination(int S[]);
void answer(int S[],int D[]);
void exploreCave(int N){
int S[N];
//int S_2[N];
// 0 0 0 0 0
// 1 1 1 1 1
// 1 1 1 1 0
//1110
//3102
int S_1[N];
int S_2[N];
for (int i=0; i<N; i++) S_2[i] = 1;
bool good[N];
int w = 0,akt=0,w_2=0,ktory=0;
while (w != -1){
if (akt == 0){
w = tryCombination(S_1);
if (w == -1){
ktory = 0;
break;
}
for (int i=0; i<N; i++){
if (!good[i]){
S_1[i] = 1;
w_2 = tryCombination(S_1);
if (w_2 == -1){
ktory = 0;
break;
}
if (w_2 < w){
S_2[i] = 0;
S_1[i] = 0;
good[i] = true;
}
else if(w_2 > w){
good[i] = true;
}
else S_1[i] = 0;
}
}
}
else{
w = tryCombination(S_2);
if (w == -1){
ktory = 1;
break;
}
for (int i=0; i<N; i++){
if (!good[i]){
S_2[i] = 0;
w_2 = tryCombination(S_2);
if (w_2 == -1){
ktory = 1;
break;
}
if (w_2 < w){
S_2[i] = 1;
S_1[i] = 1;
good[i] = true;
}
else if(w_2 > w){
good[i] = true;
}
else S_2[i] = 1;
}
}
}
akt = (akt+1)%2;
}
if (ktory == 0){
for (int i=0; i<N; i++){
S_1[i] = (S_1[i]+1)%2;
D[i] = tryCombination(S_1);
S_1[i] = (S_1[i]+1)%2;
}
}
else{
for (int i=0; i<N; i++){
S_2[i] = (S_2[i]+1)%2;
D[i] = tryCombination(S_2);
S_2[i] = (S_2[i]+1)%2;
}
}
answer(S,D);
}