| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 970578 | Acanikolic | Cave (IOI13_cave) | C++14 | 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 <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
    vector<int>S(N);
    vector<int>D(N,-1);
    for(int k = 0; k < N; k++) {
        int index = tryCombination(S);
        if(index == -1) break;
        for(int j = 0; j < N; j++) {
            if(D[j] != -1) continue;
            S[j] ^= 1;
            if(tryCombination(S) != index) {
                D[j] = index;
                break;
            }
            S[j] ^= 1;
        }
    }
    vector<int>SS(N,1);
    for(int k = 0; k < N; k++) {
        int index = tryCombination(SS);
        if(index == -1) break;
        for(int j = 0; j < N; j++) {
            if(D[j] != -1) continue;
            SS[j] ^= 1;
            if(tryCombination(SS) != index) {
                D[j] = index;
                break;
            }
            SS[j] ^= 1;
        }
    }
    answer(S,D);
}
