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 nax = 1500;
int g[nax][nax], f[nax][nax];
int n;
set<int> rem[nax+5];
void initialize(int N) {
n = N;
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
if(i!=j) g[i][j] = 1;
f[i][j] = 0;
}
}
}
bool anyIsolated() {
for(int i=0; i<n; i++) {
int cnt = 0;
for(int j=0; j<n; j++) {
cnt += g[i][j];
}
if(cnt == 0) return true;
}
return false;
}
bool allConnected() {
vector<bool> vis(n, false);
function <void(int)> rec = [&] (int node) {
vis[node] = true;
for(int i=0; i<n; i++) {
if(vis[i] == false && f[node][i] == 1) {
rec(i);
}
}
};
for(auto u : vis) if(!u) return false;
return true;
}
int hasEdge(int u, int v) {
//coba jawab no
g[u][v] = g[v][u] = 0;
if(anyIsolated()) {
g[u][v] = g[v][u] = 1;
f[u][v] = f[v][u] = 1;
}
// for(int i=0; i<n; i++) {
// for(int j=0; j<n; j++) {
// cout << f[i][j];
// }
// cout << endl;
// }
return g[u][v];
}
/*
G
sama
F
gaboleh ada node di G yang isolated dan gaboleh ada node di F yang all connected ?
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |