제출 #76706

#제출 시각아이디문제언어결과실행 시간메모리
76706liwi동굴 (IOI13_cave)C++11
0 / 100
341 ms384 KiB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define println printf("\n");
#define readln(x) getline(cin,x);
#define pb push_back
#define endl "\n"
#define MOD 1000000007
#define mp make_pair

#define MAXN 5000

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef unordered_map<int,int> umii;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,pii> triple;
typedef int8_t byte;

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}

int num_switches,ans[MAXN],on[MAXN];

void exploreCave(int N){
    num_switches = N;
    for(int s=0; s<num_switches; s++){
        int temp[MAXN];
        for(int i=0; i<num_switches; i++)
            temp[i] = 1;
        int p = tryCombination(temp);
        int low = 0, high = num_switches-1, last = p>=s||p==-1;
        
        while(low <= high){
            if(low == high){
                ans[s] = low;
                if(last) on[s] = temp[low];
                else on[s] = !temp[low];
                break;
            }
            int mid = (low+high)/2;
            memset(temp,0,sizeof temp);
            for(int i=low; i<=mid; i++)
                temp[i] = 1;
            p = tryCombination(temp);
            p = (p>=s||p==-1);
            if(p != last){
                high = mid;
                last = !last;
            }else{
                low = mid;
            }
        }
    }
    answer(on,ans);
}

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