Submission #228662

#TimeUsernameProblemLanguageResultExecution timeMemory
228662CantfindmeRonald (COCI17_ronald)C++17
120 / 120
55 ms10232 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...