제출 #120231

#제출 시각아이디문제언어결과실행 시간메모리
120231TuGSGeReL게임 (IOI14_game)C++14
0 / 100
2 ms384 KiB
#include "game.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #define ll long long #define mp make_pair #define pub push_back #define pob pop_back() #define ss second #define ff first #define mt make_tuple #define pof pop_front() #define fbo find_by_order #define ook order_of_key #define lb lower_bound #define ub upper_bound typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; using pll = pair <ll, ll>; using pii = pair <int, int>; int par[1501], sz[1501], rsz[1501], nn, rsz1[1501][1501]; int fnd(int x) { if ( par[x] != x ) return par[x] = fnd(par[x]); return par[x]; } void dsu(int u, int v) { int pru = fnd(u), prv = fnd(v); par[pru] = prv; sz[prv] += sz[pru]; rsz[prv] = rsz[pru] + rsz[prv] - rsz1[pru][prv] - rsz1[prv][pru]; } void rdsu(int u, int v) { int pru = fnd(u), prv = fnd(v); rsz1[pru][prv]++; rsz1[prv][pru]++; rsz[pru]++; rsz[prv]++; } bool tusdaa(int u, int v) { int pru = fnd(u), prv = fnd(v); if ( pru == prv ) return 1; if ( rsz[prv] + 1 == (nn - sz[prv]) * sz[prv] ) return 1; if ( rsz[pru] + 1 == (nn - sz[pru]) * sz[pru] ) return 1; return 0; } void initialize(int n) { nn = n; for (int i = 0; i < n; i++) par[i]= i, sz[i] = 1; } int hasEdge(int u, int v) { if ( !tusdaa(u, v) ) { rdsu(u, v); return 0; } else { dsu(u, v); return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...