#include <bits/stdc++.h>
using namespace std;
const int MAXN = 21;
int N;
int a[MAXN][MAXN];
void initialize(int n){
memset(a, -1, sizeof(a)); N = n;
}
//exist bad partition
bool bad(){
for (int i = 1; i < (1 << N) - 1; ++i){
bool b = 1;
for (int x = 0; x < N; ++x)
for (int y = 0; y < N; ++y)
if (!(i & (1 << x)) && (i & (1 << y)) && a[x][y] != 0) b = 0;
if (b) return 1;
}
return 0;
}
int hasEdge(int x, int y){
a[x][y] = 0, a[y][x] = 0;
if (bad()) a[x][y] = 1, a[y][x] = 1;
//cout << x << ' ' << y << " -> " << a[x][y] << endl;
return a[x][y];
}
/*int main(){
initialize(4);
hasEdge(0, 3);
hasEdge(1, 0);
hasEdge(0, 2);
hasEdge(3, 1);
hasEdge(1, 2);
hasEdge(2, 3);
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |