Submission #284167

#TimeUsernameProblemLanguageResultExecution timeMemory
284167OzyGame (IOI14_game)C++17
100 / 100
696 ms25368 KiB
#include "game.h"
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,a,b) for (lli i = (a); i <= (b); i++)
#define debug(a) cerr << #a << " = " << a << endl;

set<int> avenida;
int tabla[1502][1502];

void initialize(int n) {
    avenida.insert(0);
}

int hasEdge(int u, int v) {
    int a,c = 0;

    if (avenida.find(u) != avenida.end()) c++;
    if (avenida.find(v) != avenida.end()) c++;

    if (c == 2 || c == 0){
        tabla[u][v] = -1;
        tabla[v][u] = -1;
        return 0;
    }
    else {

        if (avenida.find(u) == avenida.end()) a = u;
        else a = v;

        c = 0;
        for (auto it = avenida.begin(); it != avenida.end(); it++) if (tabla[a][*it] == 0) c++;

        if (c == 1) {
            tabla[u][v] = 1;
            tabla[v][u] = 1;

            avenida.insert(a);

            return 1;
        }
        else {
            tabla[u][v] = -1;
            tabla[v][u] = -1;
            return 0;
        }

    }


}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...