# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25776 | 2017-06-24T06:05:34 Z | 시제연(#1082) | 전압 (JOI14_voltage) | C++ | 39 ms | 7232 KB |
#include <bits/stdc++.h> using namespace std; int n, m; vector<int> lis[100100]; vector<int> id[100100]; int color[100100]; bool dfs(int here, int avoid, int col) { int i; color[here] = col; for (i=0;i<lis[here].size();i++) { int there = lis[here][i]; if (id[here][i]==avoid) { if (color[there]) { if (color[there]!=color[here]) return false; continue; } if (!dfs(there,avoid,col)) return false; continue; } if (color[there]) { if (color[there]==color[here]) return false; continue; } if (!dfs(there,avoid,3-col)) return false; } return true; } int main() { int i, j; scanf("%d%d",&n,&m); if (n>2000||m>3000) return 0; for (i=0;i<m;i++) { int a, b; scanf("%d%d",&a,&b); a--;b--; lis[a].push_back(b); id[a].push_back(i); lis[b].push_back(a); id[b].push_back(i); } int cnt = 0; for (i=0;i<m;i++) { for (j=0;j<n;j++) color[j] = 0; if (dfs(0,i,1)) cnt++; } printf("%d\n",cnt); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 7232 KB | Output is correct |
2 | Incorrect | 0 ms | 7100 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 7100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 7100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 7100 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |