#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector <int> adj[100010];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(0);
int n;
cin >> n;
for(int i = 0;i < n;i++){
int u,v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
bool cyc = true;
for(int i =1;i <= n;i++){
if(adj[i].size() != 2){
cyc = false;
break;
}
}
if(cyc){
if(n % 4 == 0){
cout << n/2;
}else{
cout << -1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
20 ms |
5708 KB |
Output is correct |
6 |
Correct |
21 ms |
5688 KB |
Output is correct |
7 |
Correct |
21 ms |
7024 KB |
Output is correct |
8 |
Correct |
20 ms |
6992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2652 KB |
Output is correct |
3 |
Correct |
1 ms |
2652 KB |
Output is correct |
4 |
Correct |
1 ms |
2652 KB |
Output is correct |
5 |
Correct |
20 ms |
5708 KB |
Output is correct |
6 |
Correct |
21 ms |
5688 KB |
Output is correct |
7 |
Correct |
21 ms |
7024 KB |
Output is correct |
8 |
Correct |
20 ms |
6992 KB |
Output is correct |
9 |
Incorrect |
1 ms |
2652 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |