# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581730 | 2022-06-23T05:16:44 Z | 박상훈(#8364) | 전압 (JOI14_voltage) | C++14 | 62 ms | 8640 KB |
#include <bits/stdc++.h> typedef long long ll; using namespace std; vector<int> adj[100100]; pair<int, int> E[200200]; int n, m, visited[200200]; bool dfs_col(int s, int c = 0){ visited[s] = c; for (auto &v:adj[s]){ if (visited[v]<0){ if (!dfs_col(v, c^1)) return 0; } else if (visited[v]==c) return 0; } return 1; } void naive(){ int ans = 0; for (int i=1;i<=m;i++){ for (int j=1;j<=n;j++) adj[j].clear(); for (int j=1;j<=m;j++) if (i!=j){ adj[E[j].first].push_back(E[j].second); adj[E[j].second].push_back(E[j].first); } fill(visited+1, visited+n+1, -1); visited[E[i].first] = visited[E[i].second] = 0; bool flag = 1; flag &= dfs_col(E[i].first); if (visited[E[i].second] < 0) flag &= dfs_col(E[i].second); for (int j=1;j<=n;j++) if (visited[j]<0) flag &= dfs_col(j); if (flag) ans++; } printf("%d\n", ans); exit(0); } int main(){ scanf("%d %d", &n, &m); for (int i=1;i<=m;i++){ int x, y; scanf("%d %d", &x, &y); adj[x].push_back(y); adj[y].push_back(x); E[i] = {x, y}; } if (n<=1000) naive(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 2712 KB | Output is correct |
2 | Correct | 56 ms | 2684 KB | Output is correct |
3 | Incorrect | 44 ms | 2644 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 32 ms | 6844 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 6932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 8640 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |