Submission #558842

#TimeUsernameProblemLanguageResultExecution timeMemory
558842uroskCave (IOI13_cave)C++14
100 / 100
1058 ms568 KiB
#include "cave.h"
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
#define ld double
#define ll int
#define ull unsigned long long
#define llinf 100000000000000000LL // 10^17
#define iinf 2000000000 // 2*10^9
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) int(a.size())
#define all(a) a.begin(),a.end()
#define here; cerr<<"===========================\n";
#define ceri(a,l,r) {for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
    return uniform_int_distribution<ll>(l,r)(rng);
}
#define maxn 5005
ll n;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll cans[maxn];
ll cur[maxn];
bool vis[maxn];
void exploreCave(int N) {
    n = N;
    for(ll i = 0;i<n;i++) b[i] = -1;
    for(ll i = 0;i<n;i++) c[i] = 0;
    for(ll i = 0;i<n;i++){
        ll col = 0;
        //if(j==-1) j = n;
        fill(c,c+n+1,col);
        for(ll j = 0;j<n;j++) if(b[j]!=-1) c[j] = cans[j];
        ll j = tryCombination(c);
        if(j==-1) j = n;
        if(j>i) col = 1;
        fill(c,c+n+1,col);
        for(ll j = 0;j<n;j++) if(b[j]!=-1) c[j] = cans[j];
        ll l = 0,r = n-1,mid,rez;
        //here;
        //cerr<<"j: "<<i<<" "<<col<<endl;
        //ceri(c,0,n-1);
        //cerr<<j<<endl;
        while(l<=r){
            ll mid = (l+r)/2;
            for(ll i = 0;i<n;i++){
                if(b[i]!=-1) c[i] = cans[i];
                else c[i] = 1^col;
            }
            for(ll i = l;i<=mid;i++){
                if(b[i]!=-1) c[i] = cans[i];
                else c[i] = col;
            }
            //cerr<<l<< " "<<r<< " "<<mid<<endl;
            ll e = tryCombination(c);
            if(e==-1) e = n;
            //ceri(c,0,n-1);
            //cerr<<e<<endl;
            if(e==i){
                rez = mid;
                r = mid-1;
            }else l = mid+1;
        }
        cans[rez] = !col;
        b[rez] = i;
    }
    answer(cans,b);
}

Compilation message (stderr)

cave.cpp:20:9: warning: ISO C++11 requires whitespace after the macro name
   20 | #define here; cerr<<"===========================\n";
      |         ^~~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:49:26: warning: unused variable 'mid' [-Wunused-variable]
   49 |         ll l = 0,r = n-1,mid,rez;
      |                          ^~~
cave.cpp:75:16: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
   75 |         b[rez] = i;
      |         ~~~~~~~^~~
#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...