제출 #120240

#제출 시각아이디문제언어결과실행 시간메모리
120240TuGSGeReL게임 (IOI14_game)C++14
100 / 100
674 ms25256 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], can[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; for (int i = 0; i < nn; i++) rsz1[i][prv] = rsz1[prv][i] = rsz1[prv][i] + rsz1[i][pru]; } void initialize(int n) { nn = n; for (int i = 0; i < n; i++) par[i]= i, sz[i] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if ( j == i ) continue; rsz1[i][j] = 1; } } } int hasEdge(int u, int v) { int pru = fnd(u), prv = fnd(v); if ( rsz1[pru][prv] != 1 ) { rsz1[pru][prv]--; rsz1[prv][pru]--; 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...