Submission #1139455

#TimeUsernameProblemLanguageResultExecution timeMemory
1139455mychecksedad게임 (IOI14_game)C++17
100 / 100
220 ms16484 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define ll long long int #define MOD (1000000000+7) #define MOD1 (998244353) #define pb push_back #define all(x) x.begin(), x.end() #define en cout << '\n' #define ff first #define ss second #define pii pair<int,int> #define vi vector<int> const int N = 1500+100, M = 1e5+10, K = 52, MX = 30; int D[N][N]; struct Dsu { vector<int> s, p; int sz; void init(int n){ sz = n; s.resize(n, 1); p.resize(n); for(int i = 0; i < n; ++i) p[i] = i; for(int i = 0; i < n; ++i){ for(int j = 0; j < n; ++j){ D[i][j] = i == j ? 0 : 1; } } } int find(int v){ if(p[v] == v) return v; return (p[v] = find(p[v])); } void merge(int a, int b){ a = find(a); b = find(b); if(a != b){ if(s[a] > s[b]){ swap(a, b); } s[b] += s[a]; p[a] = b; sz--; for(int j = 0; j < p.size(); ++j){ if(find(j) != find(a) && find(j) == j){ int w = find(a); int x = find(j); D[w][x] = D[a][x] + D[b][x]; D[x][w] = D[w][x]; } } } } }; Dsu d; int nn; void initialize(int n) { d.init(n); nn = n; } int check(int u, int v){ if(d.find(u) == d.find(v)) return 0; if(D[d.find(u)][d.find(v)] == 1){ d.merge(u, v); return 1; } D[d.find(u)][d.find(v)]--; D[d.find(v)][d.find(u)]--; return 0; } int hasEdge(int u, int v) { if(check(u, v) == 1){ return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...