Submission #1025547

#TimeUsernameProblemLanguageResultExecution timeMemory
1025547dozerCave (IOI13_cave)C++14
51 / 100
315 ms592 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define st first
#define nd second
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define LL node * 2
#define RR node * 2 + 1
#define mid (l + r) / 2
#define ll long long
#define MAXN 200005
#define LOGN 12




void exploreCave(int N) {
    int done[N], curr[N];
    for (int i = 0; i < N; i++)
        done[i] = -1, curr[i] = 0;


    auto question = [&](int x, int val){
        int tmpx = x;
        int lst = -1;
        for (int i = 0; i < N; i++){
            if (x > 0 && done[i] == -1) curr[i] = val, x--, lst = i;
            else if (done[i] == -1) curr[i] = 1 - val;
        }
        int res = tryCombination(curr);
        return res;
    };



    for (int i = 0; i < N; i++){
        int val = 0;
        if (question(0, 1) >= i + 1 || question(0, 1) == -1){
            val = 1;
        }

        int pos = 0;
        for (int j = LOGN; j >= 0; j--){
            int tmp = pos + (1<<j);
            int t = question(tmp, val);
           // cout<<i<<sp<<val<<sp<<tmp<<sp<<t<<endl;
            if (t >= i + 1 || t == -1) pos = tmp;
        }

        pos++;
        int lst = 0;
        for (int i = 0; i < N; i++){
            if (done[i] == -1 && pos > 0) lst = i, pos--;
        }

        done[lst] = i;
        curr[lst] = 1 - val;
    }


    answer(curr, done);
}

Compilation message (stderr)

cave.cpp: In lambda function:
cave.cpp:29:13: warning: unused variable 'tmpx' [-Wunused-variable]
   29 |         int tmpx = x;
      |             ^~~~
cave.cpp:30:13: warning: variable 'lst' set but not used [-Wunused-but-set-variable]
   30 |         int lst = -1;
      |             ^~~
#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...