Submission #703526

# Submission time Handle Problem Language Result Execution time Memory
703526 2023-02-27T15:29:05 Z Pacybwoah Logičari (COCI21_logicari) C++14
20 / 110
79 ms 6888 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> graph(n);
    int a,b;
    for(int i=0;i<n;i++){
        cin>>a>>b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    if(n<=20){
        int ans=1e9;
        for(int i=0;i<(1<<n);i++){
            for(int j=0;j<n;j++){
                int cnt=0;
                for(auto x:graph[j]){
                    if(((1<<x)&i)>0){
                        cnt++;
                    }
                }
                if(cnt!=1) break;
                if(j==n-1){
                    cnt=0;
                    for(int k=0;k<n;k++){
                        if(((1<<k)&i)>0) cnt++;
                    }
                    ans=min(ans,cnt);
                }
            }
        }
        if(ans==1e9) cout<<-1<<"\n";
        else cout<<ans<<"\n";
        return 0;
    }
    if(n%4==0) cout<<n/2;
    else cout<<-1;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 67 ms 5652 KB Output is correct
6 Correct 63 ms 5656 KB Output is correct
7 Correct 63 ms 5664 KB Output is correct
8 Correct 79 ms 6888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
3 Correct 6 ms 296 KB Output is correct
4 Correct 5 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 16 ms 212 KB Output is correct
10 Correct 7 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 7 ms 292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 212 KB Output is correct
2 Correct 6 ms 212 KB Output is correct
3 Correct 6 ms 296 KB Output is correct
4 Correct 5 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 2 ms 212 KB Output is correct
9 Correct 16 ms 212 KB Output is correct
10 Correct 7 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 7 ms 292 KB Output is correct
13 Incorrect 1 ms 340 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 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 67 ms 5652 KB Output is correct
6 Correct 63 ms 5656 KB Output is correct
7 Correct 63 ms 5664 KB Output is correct
8 Correct 79 ms 6888 KB Output is correct
9 Correct 5 ms 212 KB Output is correct
10 Correct 6 ms 212 KB Output is correct
11 Correct 6 ms 296 KB Output is correct
12 Correct 5 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 2 ms 212 KB Output is correct
17 Correct 16 ms 212 KB Output is correct
18 Correct 7 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 7 ms 292 KB Output is correct
21 Incorrect 1 ms 340 KB Output isn't correct
22 Halted 0 ms 0 KB -