Submission #591650

#TimeUsernameProblemLanguageResultExecution timeMemory
591650MahtimursuCave (IOI13_cave)C++17
100 / 100
265 ms596 KiB
#include "cave.h"
#include <bits/stdc++.h>
 
using namespace std;
 
void exploreCave(int N) {
    int S[N] = {0};
    int D[N] = {0};
 
    vector<int> left;
    for (int i = 0; i < N; ++i) left.push_back(i);
 
    for (int i = 0; i < N; ++i) {
        for (int x : left) {
            S[x] = 1;
        }
 
        int cp = 0;
        int ans = tryCombination(S);
        if (ans == -1) ans = 1e9;
        if (ans > i) cp = 1;
 
        vector<int> pos = left;
        vector<int> a, b;
        while (pos.size() > 1) {
            a.clear(); b.clear();
            for (int x : pos) {
                if (a.size() < b.size()) a.push_back(x);
                else b.push_back(x);
            }
 
            for (int x : a) S[x] = cp;
            for (int x : b) S[x] = 1 - cp;
 
            int ans = tryCombination(S);
            if (ans == -1) ans = 1e9;
            if (ans > i) pos = a;
            else pos = b;
        }
        
 
        D[pos[0]] = i;
        S[pos[0]] = cp;
 
        left.erase(find(left.begin(), left.end(), pos[0]));
    }
 
    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...