# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
581782 | 2022-06-23T06:17:31 Z | 반딧불(#8365) | 전압 (JOI14_voltage) | C++14 | 67 ms | 13232 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, m; vector<pair<int, int> > link[200002]; int ans; bool vv[200002]; bool visited[200002]; vector<int> cycle; bool findCycle(int x){ cycle.push_back(x); if(vv[x]) return true; vv[x]=1; for(auto y: link[x]){ if(visited[y.second]) continue; visited[y.second] = 1; if(findCycle(y.first)) return true; visited[y.second] = 0; } cycle.pop_back(); vv[x]=0; return false; } int main(){ scanf("%d %d", &n, &m); assert(n==m); for(int i=1; i<=m; i++){ int x, y; scanf("%d %d", &x, &y); assert(x!=y); link[x].push_back(make_pair(y, i)); link[y].push_back(make_pair(x, i)); } assert(findCycle(1)); cycle.erase(cycle.begin(), find(cycle.begin(), cycle.end(), cycle.back())+1); int len = (int)cycle.size(); if(len%2) ans = n; else ans = n-len; printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 9940 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 54 ms | 9104 KB | Output is correct |
2 | Correct | 67 ms | 13232 KB | Output is correct |
3 | Incorrect | 35 ms | 9064 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 9940 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 7 ms | 9940 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |