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>
#define fi first
#define se second
using namespace std;
int n;
vector<vector<int>> edge, con;
int aux = 0;
void initialize(int N) {
n = N;
edge = con = vector<vector<int>>(n, vector<int>(n, 0));
}
int hasEdge(int u, int v) {
for (int i = 0; i < n; ++i) {
++edge[u][i]; ++edge[i][u];
++edge[v][i]; ++edge[i][v];
}
if (edge[u][v] == 2) {
for (int i = 0; i < n; ++i) {
if (i != v) {
++con[i][u];
++con[u][i];
} else if (i != u) {
++con[i][v];
++con[v][i];
}
}
return 1;
}
bool ok1 = true;
for (int i = 0; i < n; ++i) {
if (i == v) continue;
if (edge[i][v] == 2*(n-1) && !con[i][v]) {
ok1 = false;
}
}
bool ok2 = true;
for (int i = 0; i < n; ++i) {
if (i == u) continue;
if (edge[i][u] == 2*(n-1) && !con[i][u]) {
ok2 = false;
}
}
if (!ok1 || !ok2) {
for (int i = 0; i < n; ++i) {
++edge[u][i]; ++edge[i][u];
++edge[v][i]; ++edge[i][v];
if (i != v) {
++con[i][u];
++con[u][i];
} else if (i != u) {
++con[i][v];
++con[v][i];
}
}
return 1;
}
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... |