이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 1010;
int n,e;
int edge[maxn][maxn];
int flip[maxn];
int32_t main() {
FAST
cin >> n >> e;
for (int i =0;i<e;i++) {
int a,b; cin >> a >> b;
edge[a][b] = edge[b][a] = 1;
}
for (int i =2; i<= n;i++) {
if (!edge[1][i]) flip[i] = 1;
}
bool fail = false;
for (int a = 1; a<= n;a++) {
for (int b = 1; b <= n; b++) {
if (a == b) continue;
//cout << "a:" << a << " b:" << b << "\n";
//cout << flip[a] << " " << flip[b] << " " << edge[a][b] << "\n";
if (flip[a] and !flip[b] and edge[a][b]) fail = true;
if (flip[b] and !flip[a] and edge[a][b]) fail = true;
if (!flip[a] and !flip[b] and !edge[a][b]) fail = true;
//cout << fail << "\n";
}
}
memset(flip,0,sizeof flip);
flip[1] = 1;
for (int i =2; i<= n;i++) {
if (edge[1][i]) flip[i] = 1;
}
for (int a = 1; a<= n;a++) {
for (int b = 1; b <= n; b++) {
if (a == b) continue;
if (flip[a] and !flip[b] and edge[a][b]) fail = true;
if (flip[b] and !flip[a] and edge[a][b]) fail = true;
if (!flip[a] and !flip[b] and !edge[a][b]) fail = true;
}
}
if (fail) cout << "NE";
else cout << "DA";
}
# | 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... |