Submission #622837

#TimeUsernameProblemLanguageResultExecution timeMemory
622837yuto1115Game (IOI14_game)C++17
42 / 100
1095 ms41624 KiB
#include "game.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); ++i) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); ++i) #define rrep(i, n) for(ll i = ll(n) - 1; i >= 0; --i) #define rrep2(i, n, t) for(ll i = ll(n) - 1; i >= ll(t); --i) #define pb push_back #define eb emplace_back #define all(a) a.begin(), a.end() #define SZ(a) int(a.size()) using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; const int inf = 1001001001; const ll linf = 1001001001001001001; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } int n; vi r; set<int> rs; map<P, int> mp; void initialize(int N) { n = N; r.resize(n); iota(all(r), 0); rep(i, n) rs.insert(i); rep(i, n) rep(j, n) mp[{i, j}] = 1; } int hasEdge(int u, int v) { u = r[u]; v = r[v]; assert(u != v); if (mp[{u, v}] > 1) { --mp[{u, v}]; --mp[{v, u}]; return 0; } else { rep(i, n) if (r[i] == v) r[i] = u; rs.erase(v); for (int i: rs) { if (i != u) { mp[{u, i}] += mp[{v, i}]; mp[{i, u}] += mp[{v, i}]; } } return 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...