# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156079 | 2019-10-03T07:58:07 Z | IOrtroiii | 전압 (JOI14_voltage) | C++14 | 65 ms | 19576 KB |
#include <bits/stdc++.h> using namespace std; const int N = 100100; int n, m; vector<int> g[N]; vector<int> tr[N]; int cnt[N]; int ds[N]; int bad; void dfs1(int v) { for (int u : g[v]) { if (ds[u] && ds[u] < ds[v] - 1) { if ((ds[v] & 1) == (ds[u] & 1)) { ++bad; cnt[v]++; cnt[u]--; } else { cnt[v]--; cnt[u]++; } } else if (!ds[u]) { ds[u] = ds[v] + 1; tr[v].emplace_back(u); dfs1(u); } } } void dfs2(int v) { for (int u : tr[v]) { dfs2(u); cnt[v] += cnt[u]; } } int main() { scanf("%d %d", &n, &m); for (int i = 1; i <= m; ++i) { int v, u; scanf("%d %d", &v, &u); g[v].emplace_back(u); g[u].emplace_back(v); } for (int i = 1; i <= n; ++i) { if (!ds[i]) { ds[i] = 1; dfs1(i); } } for (int i = 1; i <= n; ++i) { if (ds[i] == 1) { dfs2(i); } } int ans = 0; for (int i = 1; i <= n; ++i) { if (ds[i] > 1 && cnt[i] == bad) { ++ans; } } ans += (bad == 1); printf("%d\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 7 ms | 5240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 55 ms | 10992 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 10620 KB | Output is correct |
2 | Correct | 60 ms | 19456 KB | Output is correct |
3 | Incorrect | 64 ms | 19576 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 65 ms | 11744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |