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 "game.h"
#include <bits/stdc++.h>
#define lb lower_bound
#define LINE "------------\n"
using namespace std;
using PII = pair <int, int>;
const int N = 1500;
bool path[N][N];
int n;
void initialize(int _n) {
n = _n;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
path[i][j] = path[j][i] = 1;
}
int hasEdge(int u, int v) {
path[u][v] = path[v][u] = 0;
bool vis[n]; memset(vis, 0, sizeof(vis));
queue <int> bfs;
bfs.push(u); vis[u] = 1;
int reach = 0;
while(!bfs.empty()) {
reach++;
int x = bfs.front(); bfs.pop();
for (int i = 0; i < n; i++) {
if (path[x][i] && !vis[i]) {
bfs.push(i); vis[i] = 1;
}
}
}
if (reach != n) path[u][v] = path[v][u] = 1;
return reach != n;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |