제출 #249684

#제출 시각아이디문제언어결과실행 시간메모리
249684muhammad_hokimiyon동굴 (IOI13_cave)C++14
100 / 100
433 ms632 KiB
#include "cave.h"
#include <bits/stdc++.h>

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e9 + 7;
const int M = 26;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


void exploreCave(int N)
{
    vector < pair < int , int > > ans(N , {0 , 0});
    vector < int > used(N , 0);
    for( int i = 0; i < N; i++ ){
        int s[N] = {};
        for( int j = 0; j < N; j++ ){
            if( used[j] )s[j] = ans[j].se;
        }
        int x = tryCombination(s);
        if( x <= i && x != -1 )x = 1;
        else x = 0;
        int l1 = 0;
        int l = 0 , r = N - 1;
        for( int j = 0; j < N; j++ ){
            if( used[j] ){
                s[j] = ans[j].se;
            }
            else s[j] = 1 - x;
        }
        while( l < r ){
            int m = (l + r) / 2;
            for( int j = l1; j <= m; j++ ){
                if( !used[j] ){
                    s[j] = x;
                }
            }
            int xx = tryCombination(s);
            if( xx > i || xx == -1 ){
                for( int j = l1; j <= m; j++ ){
                    if( !used[j] ){
                        s[j] = 1 - x;
                    }
                }
                r = m;
            }
            else{
                l = m + 1;
                l1 = m + 1;
            }
        }
        ans[l] = { i , x };
        used[l] = 1;
    }
    int S[N];
    int D[N];
    for( int i = 0; i < N; i++ ){
        S[i] = ans[i].se;
        D[i] = ans[i].fi;
    }
    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...