Submission #545972

#TimeUsernameProblemLanguageResultExecution timeMemory
545972LunaMemeCave (IOI13_cave)C++14
0 / 100
2 ms724 KiB
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
typedef vector<int> vi;
typedef long long ll;
#define PB push_back
#define MP make_pair
#define FOR(i, x, y) for (int i = x; i < y ; i ++)

int opp(int d){
    if (d == 1)return 0;
    return 1;
}
void exploreCave(int N) {
    int arr[N];
    memset(arr, -1, sizeof arr);
    int ans[2][N];
    FOR(i, 0, N){
        int temp[N];
        memset(temp, 0, sizeof temp);
        int j = tryCombination(temp);
        int d = 0; //d is colour of i th switch
        if (j <= i && j > -1){
            d = 1;
            memset(temp, 1, sizeof temp);
        }
        //binary search

        int l = 0, r = N - 1;
        while(l < r){
            int m = (l + r) / 2;
            FOR(k, l, m + 1){
                if (arr[i] == -1)
                    temp[i] = opp(d);
            }
            j = tryCombination(temp);
            if (j > i || j == -1) //passes
            {
                l = m + 1;
            }
            else{
                r = m;
            }
        }
        assert(l == r);
        assert(arr[l] == -1);
        arr[l] = d;
        ans[l][0] = d;
        ans[l][1] = i;
    }
    answer(ans[1], ans[0]);
}
#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...