Submission #1186810

#TimeUsernameProblemLanguageResultExecution timeMemory
1186810astoriaGame (IOI14_game)C11
Compilation error
0 ms0 KiB
#include "game.h"            // <<<  organiser’s header
#include "bits/stdc++.h"

using namespace std;

static const int MAXN = 1500 + 5;
static int parent_[MAXN], sz_[MAXN];
static int components, n, maxSize;
static long long remaining;

static int Find(int v) { return parent_[v]==v ? v : parent_[v]=Find(parent_[v]); }
static void Unite(int a,int b){
    a=Find(a); b=Find(b); if(a==b) return;
    if(sz_[a]<sz_[b]) swap(a,b);
    parent_[b]=a; sz_[a]+=sz_[b];
    --components; maxSize=max(maxSize,sz_[a]);
}

/*  The header already has `extern "C"` when compiled as C++,  
    so we just write the definitions.                       */
void initialize(int N)
{
    n=N;
    for(int i=0;i<n;i++){ parent_[i]=i; sz_[i]=1; }
    components=n;
    remaining=1LL*n*(n-1)/2;
    maxSize=1;
}

int hasEdge(int u,int v)
{
    --remaining;

    if(Find(u)==Find(v)) return 0;               // inside one component

    bool mustMerge = (components-2) > remaining;            // condition (1)
    int  newMax    = max(maxSize, sz_[Find(u)] + sz_[Find(v)]);
    bool safeMerge = 1LL*newMax*(n-newMax) > remaining;     // condition (2)

    if(mustMerge && safeMerge){
        Unite(u,v);
        return 1;
    }
    return 0;
}

Compilation message (stderr)

game.c:2:10: fatal error: bits/stdc++.h: No such file or directory
    2 | #include "bits/stdc++.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.