This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "game.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define lb lower_bound
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
int N, par[1501], adj[1501][1501];
vector<int> S[1501];
void initialize(int n) {
N = n;
for(int l = 0; l < N; l++) {
par[l] = l;
S[l].pb(l);
for(int i = 0; i < N; i++)
adj[l][i] = 1;
}
}
void unionSet(int u, int v) {
if(S[u].size() < S[v].size()) swap(u, v);
for(auto e : S[v]) {
S[u].pb(e); par[e] = u;
}
for(int l = 0; l < N; l++)
adj[u][l] = adj[l][u] = adj[u][l] + adj[v][l];
}
int hasEdge(int u, int v) {
u = par[u], v = par[v];
if(u == v) return 0;
if(adj[u][v] > 1) {
adj[u][v]--, adj[v][u]--;
return 0;
}
unionSet(u, v);
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |