Submission #1164723

#TimeUsernameProblemLanguageResultExecution timeMemory
1164723tsengangCave (IOI13_cave)C++20
100 / 100
201 ms548 KiB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
#define ll long long
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ertunt return
#define vodka void

vodka exploreCave(int n){
    int v[n], d[n], s[n], vis[n] = {};
    for(int i = 0; i < n; i++){
        int sz = 0;
        for(int j = 0; j < n; j++){
            if(!vis[j]) s[sz++] = j;
        }
        for(int j = 0; j < sz; j++) d[s[j]] = 0;
        int l = 0, r = sz - 1;
        int x = tryCombination(d);
        int q = 0, p = 1;
        if(x == i) swap(q, p);
        while(l < r){
            int mid = (l + r) / 2;
            for(int j = 0; j < sz; j++){
                d[s[j]] = (j <= mid ? q : p);
            }
            int x = tryCombination(d);
            if(x == -1 or x > i) r = mid;
            else l = mid + 1;
        }
        v[s[l]] = i;
        d[s[l]] = q;
        vis[s[l]] = 1;
    }
    answer(d, v);
}
#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...