Submission #742207

# Submission time Handle Problem Language Result Execution time Memory
742207 2023-05-15T19:10:42 Z sword060 Logičari (COCI21_logicari) C++17
20 / 110
57 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int x; cin>>x;
	if(x>20){
		cout<<(x%4?-1:x/2);
		return 0;
	}
	vector<int>v[x];
	for(int i=1;i<=x;i++){
		int l,r;cin>>l>>r;
		l--;r--;
		v[l].push_back(r);
		v[r].push_back(l);
	}
	int ans=1e9;
	for(int i=1;i<(1<<x);i++){
		bool f=1;
		for(int j=0;j<x;j++){
			int cnt=0;
			for(auto c:v[j])
				if(i&(1<<c))cnt++;
			f&=(cnt==1);
		}
		if(f)
			ans=min(ans,__builtin_popcount(i));
	}
	cout<<(ans==1e9?-1:ans);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 212 KB Output is correct
2 Correct 45 ms 212 KB Output is correct
3 Correct 47 ms 332 KB Output is correct
4 Correct 48 ms 308 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 21 ms 320 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 11 ms 316 KB Output is correct
9 Correct 48 ms 212 KB Output is correct
10 Correct 57 ms 260 KB Output is correct
11 Correct 6 ms 320 KB Output is correct
12 Correct 47 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 212 KB Output is correct
2 Correct 45 ms 212 KB Output is correct
3 Correct 47 ms 332 KB Output is correct
4 Correct 48 ms 308 KB Output is correct
5 Correct 0 ms 316 KB Output is correct
6 Correct 21 ms 320 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 11 ms 316 KB Output is correct
9 Correct 48 ms 212 KB Output is correct
10 Correct 57 ms 260 KB Output is correct
11 Correct 6 ms 320 KB Output is correct
12 Correct 47 ms 296 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 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 328 KB Output is correct
9 Correct 45 ms 212 KB Output is correct
10 Correct 45 ms 212 KB Output is correct
11 Correct 47 ms 332 KB Output is correct
12 Correct 48 ms 308 KB Output is correct
13 Correct 0 ms 316 KB Output is correct
14 Correct 21 ms 320 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 11 ms 316 KB Output is correct
17 Correct 48 ms 212 KB Output is correct
18 Correct 57 ms 260 KB Output is correct
19 Correct 6 ms 320 KB Output is correct
20 Correct 47 ms 296 KB Output is correct
21 Incorrect 1 ms 212 KB Output isn't correct
22 Halted 0 ms 0 KB -