Submission #241265

#TimeUsernameProblemLanguageResultExecution timeMemory
241265Coroian_DavidGame (IOI14_game)C++11
15 / 100
6 ms768 KiB
#include <bits/stdc++.h>

#include "game.h"

#define MAX_N 1500

using namespace std;

int ap[MAX_N + 1];

int pos[MAX_N + 1][MAX_N + 1];

int N;

void initialize(int n)
{
    N = n;
    for(int i = 1; i <= n; i ++)
    {
        ap[i] = n - 1;

        for(int j = 1; j <= n; j ++)
        {
            if(i != j)
                pos[i][j] = 1;
        }
    }
}

void verif(int a)
{
    int n = N;
    if(ap[a] != 1)
        return;

    //cout << "BAGAM LA " << a << "\n";

    for(int i = 1; i <= n; i ++)
    {
        if(i != a && ap[i] > 0 && pos[a][i] == 1)
        {
          //  cout << "SE COMBINA CU " << i << "\n";

            pos[a][i] = pos[i][a] = 2;
            ap[i] --;
            ap[a] --;

            verif(i);

            return;
        }
    }
}

int hasEdge(int u, int v)
{
    u ++;
    v ++;

    int rez = 0;
    if(pos[u][v] == 2)
    {
        rez = 1;
    }

    else
    {
        ap[u] --;
        ap[v] --;
        pos[u][v] = pos[v][u] = 0;
    }

    verif(u);
    verif(v);

    return rez;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...