| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1113757 | vladilius | Cave (IOI13_cave) | C++17 | 254 ms | 760 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;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
void exploreCave(int n){
    int b[n], p[n], s[n];
    vector<int> ch;
    for (int i = 0; i < n; i++) ch.pb(i);
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++) s[j] = 0;
        for (int j = 0; j < i; j++){
            s[p[j]] = b[j];
        }
        int f = tryCombination(s), d = (f == i);
        b[i] = d;
        int l = 0, r = (int) ch.size() - 1;
        
        auto check = [&](int m){
            for (int j = 0; j <= m; j++){
                s[ch[j]] = d;
            }
            for (int j = m + 1; j < ch.size(); j++){
                s[ch[j]] = !d;
            }
            int f = tryCombination(s);
            return (f != i);
        };
        
        while (l + 1 < r){
            int m = (l + r) / 2;
            if (check(m)){
                r = m;
            }
            else {
                l = m + 1;
            }
        }
        if (check(l)) r = l;
        p[i] = ch[r];
        ch.erase(ch.begin() + r);
    }
    int x[n], y[n];
    for (int i = 0; i < n; i++){
        x[p[i]] = i;
        y[p[i]] = b[i];
    }
    
    answer(y, x);
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
