# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
25757 | 2017-06-24T05:14:01 Z | 서규호(#1081) | 전압 (JOI14_voltage) | C++14 | 63 ms | 9596 KB |
#include <bits/stdc++.h> #define lld long long #define pp pair<int,int> #define pb push_back #define MOD 1000000007 #define left lleft #define right rright #define INF 2000000000 #define Linf 1000000000000000000LL #define next nnext #define minus mminus using namespace std; int N,M; int color[100002]; bool check[100002]; vector<int> edge[100002]; bool bipartite; void dfs(int x){ check[x] = true; for(auto &i : edge[x]){ if(color[i] == color[x]) bipartite = false; else color[i] = 3-color[x]; if(check[i]) continue; dfs(i); } } int main(){ scanf("%d %d",&N,&M); for(int i=1; i<=M; i++){ int x,y; scanf("%d %d",&x,&y); edge[x].pb(y); edge[y].pb(x); } int cnt = 0,it; for(int i=1; i<=N; i++){ if(check[i]) continue; bipartite = true; color[i] = 1; dfs(i); if(!bipartite){ it = i; cnt++; } } if(cnt >= 2){ puts("0"); return 0; }else if(cnt == 0){ printf("%d\n",N); return 0; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 4852 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 8568 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 49 ms | 8568 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 63 ms | 9596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |