제출 #257760

#제출 시각아이디문제언어결과실행 시간메모리
257760HeheheCave (IOI13_cave)C++14
12 / 100
227 ms760 KiB
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
#include "cave.h"

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

const int N = 1e4 + 11;

int q[N], d[N], s[N];
vector<int>pos;

bool check(int l, int r, int t){

    for(int i = l; i <= l; i++){
        q[pos[i]] = !q[pos[i]];
    }

    int x = tryCombination(q);

    for(int i = l; i <= l; i++){
        q[pos[i]] = !q[pos[i]];
    }

    return (x > t || x == -1);
}

void exploreCave(int n){

    memset(s, -1, sizeof(s));

    for(int i = 0; i < n; i++){

        int x = tryCombination(q);

        pos.clear();

        for(int j = 0; j < n && x != i; j++){
            if(s[j] == -1){
                q[j] = !q[j];
            }
        }

        for(int j = 0; j < n; j++){
            if(s[j] == -1){
                pos.push_back(j);
            }
        }

        int l = 0, r = sz(pos) - 1;
        while(l < r){
            int mid = (l + r) >> 1;
            if(check(l, mid, i))r = mid;else l = mid + 1;
        }

        s[pos[l]] = q[pos[l]] = !q[pos[l]];
        d[pos[l]] = i;
    }

    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...