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;
set<int> adj[1501];
bool vis[1501]; int curr, t, N;
void initialize(int n) {
N = n;
for(int l = 0; l < n; l++) {
for(int i = 0; i < n; i++) {
if(l == i) continue;
adj[l].insert(i);
}
}
curr = (n * (n - 1)) / 2;
}
int hasEdge(int u, int v) {
if(curr == N - 1 && t == 0) {
vis[u] = 1, vis[v] = 1;
curr--; t++; return 1;
}
curr--;
if(!vis[u] && !vis[v]) {
if(adj[u].size() == 1 || adj[v].size() == 1) {
vis[u] = vis[v] = 1;
t++; return 1;
}
adj[u].erase(v), adj[v].erase(u);
return 0;
}
if(vis[u] && vis[v]) {
t++; return 1;
}
if(vis[u]) swap(u, v);
if(adj[u].size() == 1) {
vis[u] = 1; t++; return 1;
}
adj[u].erase(v), adj[v].erase(u);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |