Submission #76708

# Submission time Handle Problem Language Result Execution time Memory
76708 2018-09-16T03:43:52 Z liwi Cave (IOI13_cave) C++11
0 / 100
362 ms 512 KB
#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 time Memory Grader output
1 Incorrect 76 ms 512 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 362 ms 512 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 424 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 424 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 512 KB too much calls on tryCombination()
2 Halted 0 ms 0 KB -