Submission #950599

#TimeUsernameProblemLanguageResultExecution timeMemory
950599quanlt206Game (IOI14_game)C++17
42 / 100
1073 ms4700 KiB
#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; 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) 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) { if (u > v) swap(u, v); c[u][v] = false; if (check_connected()) return 0; c[u][v] = true; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...