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>
using namespace std;
const int mxn = 1505;
int n;
bool adj[mxn][mxn];
bool seen[mxn][mxn];
bool visited[mxn];
void initialize(int N) {
n = N;
}
void get_comp(int u, vector<int> &comp) {
visited[u] = true;
comp.push_back(u);
for(int v = 0; v < n; v++) if(u != v && !visited[v] && adj[u][v]) {
get_comp(v, comp);
}
}
int hasEdge(int u, int v) {
vector<int> compu, compv;
fill(visited, visited+mxn, false);
get_comp(u, compu);
fill(visited, visited+mxn, false);
get_comp(v, compv);
// cerr << "compu:\n";
// for(int i : compu) cerr << i << " ";
// cerr << "\n";
// cerr << "compv:\n";
// for(int i : compv) cerr << i << " ";
// cerr << "\n";
int cnt = 0;
for(int cu : compu) for(int cv : compv) {
if(seen[cu][cv]) cnt++;
}
seen[u][v] = seen[v][u] = true;
if(cnt == (int)compu.size()*(int)compv.size()-1) {
adj[u][v] = adj[v][u] = true;
}
return adj[u][v];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |