답안 #869551

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
869551 2023-11-04T17:07:58 Z JoksimKaktus Logičari (COCI21_logicari) C++17
10 / 110
21 ms 7024 KB
#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;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -