This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "game.h"
#include<bits/stdc++.h>
#define X first
#define Y second
#define all(x) begin(x), end(x)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, b, a) for(int i = (b); i >= (a); i--)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define mxx max_element
#define mnn min_element
#define SQR(x) (1LL * (x) * (x))
#define MASK(i) (1LL << (i))
#define Point Vector
#define left Left
#define right Right
#define div Div
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair<db, db> pdb;
typedef pair<ld, ld> pld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef pair<ll, int> pli;
typedef pair<ll, pii> plii;
template<class A, class B>
    bool maximize(A& x, B y) {
        if (x < y) return x = y, true; else return false;
    }
template<class A, class B>
    bool minimize(A& x, B y) {
        if (x > y) return x = y, true; else return false;
    }
/* END OF TEMPLATE */
const int N = 1507;
bool c[N][N];
int n;
int deg[N];
struct DSU {
    int par[N], sz[N];
    DSU() {
        REP(i, 0, N) par[i] = i, sz[i] = 1;
    }
    int FS(int v) {
        return v == par[v] ? v : (par[v] = FS(par[v]));
    }
    void US(int a, int b) {
        a = FS(a);
        b = FS(b);
        if (a == b) return ;
        if (sz[a] > sz[b]) swap(a, b);
        par[a] = b;
        sz[b]+=sz[a];
    }
    void Init(int n) {
        FOR(i, 0, n) par[i] = i, sz[i] = 1;
    }
} dsu;
void initialize(int m) {
    n = m;
    REP(i, 0, n) deg[i] = n - 1;
    REP(i, 0, n)
        REP(j, i + 1, n) c[i][j] = true;
}
bool check_connected() {
    dsu.Init(n);
    REP(i, 0, n)
        REP(j, i + 1, n)
            if (c[i][j]) dsu.US(i, j);
    REP(i, 1, n)
        if (dsu.FS(i) != dsu.FS(i - 1)) return false;
    return true;
}
int hasEdge(int u, int v) {
//    REP(i, 0, n) cout<<deg[i]<<" "; cout<<"\n";
    if (u > v) swap(u, v);
    c[u][v] = false;
    if (deg[u] > 15 && deg[v] > 15) {
        deg[u]--;
        deg[v]--;
        return 0;
    }
    if (check_connected()) {
        deg[u]--;
        deg[v]--;
        return 0;
    }
    c[u][v] = true;
    return 1;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |