Submission #114716

#TimeUsernameProblemLanguageResultExecution timeMemory
114716toonewbieGame (IOI14_game)C++17
100 / 100
929 ms38392 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1555;

int n;
vector <int> g[N];
int has[N][N];
void initialize(int N) {
    n = N;
    memset(has, -1, sizeof(has));
    for (int i = 1; i <= n; i++) {
        has[i][i] = 1;
        g[i].push_back(i);
    }
}

int hasEdge(int u, int v) {
    u++, v++;
    for (int i : g[u]) {
        for (int j : g[v]) {
            if (i == u && j == v) continue;
            if (has[i][j] == -1) {
                return has[u][v] = has[v][u] = 0;
            }
        }
    }
    int x = g[u].size(), y = g[v].size();
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            int a = g[u][i], b = g[v][j];
            if (has[a][b] != 1) {
                has[a][b] = has[b][a] = 1;
                g[a].push_back(b);
                g[b].push_back(a);
            }
        }
    }
    return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...