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 N 1005
using namespace std;
bool adj[N][N];
int n,m;
bool calc(){
vector<int> ch;
for(int i=2;i<=n;i++){
if(!adj[1][i]){
ch.push_back(i);
}
}
for(auto u:ch){
for(int i=1;i<=n;i++){
if(u != i)
adj[u][i] = adj[i][u] = !adj[u][i];
}
}
int cnt = 0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cnt += adj[i][j];
}
}
return cnt == (n*(n-1));
}
int main(){
cin >> n >> m;
for(int i=0;i<m;i++){
int a,b;
cin >> a >> b;
adj[a][b] = 1;
adj[b][a] = 1;
}
bool ok = calc();
for(int i=2;i<=n;i++){
adj[1][i] = adj[i][1] = !adj[1][i];
}
ok |= calc();
cout << (ok?"DA":"NE") << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |