제출 #246403

#제출 시각아이디문제언어결과실행 시간메모리
246403NONAMERonald (COCI17_ronald)C++14
120 / 120
47 ms512 KiB
#include <bits/stdc++.h> #define dbg(x) cerr << #x << " = " << x << "\n" #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie() using namespace std; using ll = long long; using ld = long double; const int N = 1e4; int pr[N], cnt[N], e[N]; int f(int x) { return (x == pr[x]) ? x : pr[x] = f(pr[x]); } int main() { fast_io; int n, m; cin >> n >> m; if (m == 0 && n > 2) return void(cout << "NE\n"), 0; for (int i = 0; i < n; ++i) pr[i] = i, cnt[i] = 1, e[i] = 0; for (int i = 0; i < m; ++i) { int v, u; cin >> v >> u; --v, --u; if (f(v) == f(u)) ++e[f(v)]; else { cnt[f(v)] += cnt[f(u)]; e[f(v)] += e[f(u)] + 1; } pr[f(u)] = f(v); } for (int i = 0; i < n; ++i) if ((cnt[f(i)] * (cnt[f(i)] - 1) / 2) != e[f(i)]) return void(cout << "NE\n"), 0; cout << "DA\n"; }
#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...