제출 #285909

#제출 시각아이디문제언어결과실행 시간메모리
285909amalla동굴 (IOI13_cave)C++17
12 / 100
43 ms512 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
int S[10000], D[10000], n, first;
bool never = true, picked[10000];

void solve(int curr) {
    int ans;
    for (int i = 0; i<n; ++i) { // intenta la puerta S[i]
        if (picked[i]) continue;
        S[i] ^= 1;
        ans = tryCombination(S);
        if (ans!=first) {
            picked[i] = 1;
            D[ans] = i;
            if (ans>first) first = ans;
        }
        if (ans == curr) {
            D[curr] = i;
            picked[i] = 1;
            S[i] ^= 1;
            return;
        }
        S[i] ^= 1;
        ans = tryCombination(S);
        if (ans == curr) {
            D[curr] = i;
            picked[i] = 1;
            S[i] ^= 1;
            return;
        }
    }
}

void exploreCave(int N) {
    n = N;    
    for (int i = 0; i<10000; ++i) {
        S[i] = 0;
        D[i] = -1;
        picked[i] = 0;
    }
    first = tryCombination(S);
    for (int i = 0; i<N; ++i) { // para la puerta D[i]
        if (picked[i]) continue;
        solve(i);      
    }
    answer(S, D);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...