Submission #655517

# Submission time Handle Problem Language Result Execution time Memory
655517 2022-11-04T15:40:51 Z google Logičari (COCI21_logicari) C++17
20 / 110
138 ms 1492 KB
#include<bits/stdc++.h>
using namespace std;
int n,a,b;
vector<pair<int,int>> e;
int main(){
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for (int i = 0;i<n;i++){
        cin >> a >> b;e.push_back({a-1,b-1});
    }
    int ans = 100;
    if (n > 20) {
        if (n%4 == 0) cout << n/2;
        else cout << -1;
        return 0;
    }
    for (int mask = 0;mask<1<<n;mask++){
        vector<int> cnt(n,0);
        for (int i = 0;i<n;i++){
            if ((1<<e[i].second)&mask) cnt[e[i].first]++;
            if ((1<<e[i].first)&mask) cnt[e[i].second]++;
        }
        int pos = 1;
        for (int i = 0;i<n;i++){
            if (cnt[i] != pos){
                pos = 0;
                break;
            }
        }
        if (pos) ans = min(ans,__popcount(mask));
    }
    if (ans == 100) ans = -1;
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 15 ms 1492 KB Output is correct
6 Correct 21 ms 1388 KB Output is correct
7 Correct 16 ms 1492 KB Output is correct
8 Correct 15 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 212 KB Output is correct
2 Correct 138 ms 300 KB Output is correct
3 Correct 123 ms 212 KB Output is correct
4 Correct 129 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 65 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 32 ms 212 KB Output is correct
9 Correct 114 ms 212 KB Output is correct
10 Correct 113 ms 212 KB Output is correct
11 Correct 16 ms 316 KB Output is correct
12 Correct 124 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 212 KB Output is correct
2 Correct 138 ms 300 KB Output is correct
3 Correct 123 ms 212 KB Output is correct
4 Correct 129 ms 308 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 65 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 32 ms 212 KB Output is correct
9 Correct 114 ms 212 KB Output is correct
10 Correct 113 ms 212 KB Output is correct
11 Correct 16 ms 316 KB Output is correct
12 Correct 124 ms 212 KB Output is correct
13 Incorrect 1 ms 212 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 15 ms 1492 KB Output is correct
6 Correct 21 ms 1388 KB Output is correct
7 Correct 16 ms 1492 KB Output is correct
8 Correct 15 ms 1492 KB Output is correct
9 Correct 129 ms 212 KB Output is correct
10 Correct 138 ms 300 KB Output is correct
11 Correct 123 ms 212 KB Output is correct
12 Correct 129 ms 308 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 65 ms 304 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 32 ms 212 KB Output is correct
17 Correct 114 ms 212 KB Output is correct
18 Correct 113 ms 212 KB Output is correct
19 Correct 16 ms 316 KB Output is correct
20 Correct 124 ms 212 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -