#include <iostream>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <map>
#include <deque>
#include <stdio.h>
using namespace std;
int new_max (int a, int b) {
if (a == -1) return b;
if (b == -1) return a;
return max(a, b);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector<pair<int,int>> edges;
for (int i = 0; i < N; i++) {
int u, v; cin >> u >> v; --u; --v;
edges.emplace_back(u, v);
}
int lst = -1;
for (int i = 0; i < (1 << N); i++) {
vector<int> cnt;
cnt.assign(N, 0);
for (auto& p: edges) {
if (i & (1 << p.first)) cnt[p.second]++;
if (i & (1 << p.second)) cnt[p.first]++;
}
bool fine = true;
for (int i = 0; i < cnt.size(); i++) {
fine &= (cnt[i] == 1);
}
if (fine) {
lst = new_max(lst, __builtin_popcount(i));
}
}
cout << lst;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (int i = 0; i < cnt.size(); i++) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
20 ms |
2640 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
308 KB |
Output is correct |
2 |
Correct |
166 ms |
300 KB |
Output is correct |
3 |
Correct |
144 ms |
304 KB |
Output is correct |
4 |
Correct |
154 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
73 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
38 ms |
212 KB |
Output is correct |
9 |
Correct |
137 ms |
316 KB |
Output is correct |
10 |
Correct |
133 ms |
300 KB |
Output is correct |
11 |
Correct |
21 ms |
212 KB |
Output is correct |
12 |
Correct |
154 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
144 ms |
308 KB |
Output is correct |
2 |
Correct |
166 ms |
300 KB |
Output is correct |
3 |
Correct |
144 ms |
304 KB |
Output is correct |
4 |
Correct |
154 ms |
312 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
73 ms |
300 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
38 ms |
212 KB |
Output is correct |
9 |
Correct |
137 ms |
316 KB |
Output is correct |
10 |
Correct |
133 ms |
300 KB |
Output is correct |
11 |
Correct |
21 ms |
212 KB |
Output is correct |
12 |
Correct |
154 ms |
300 KB |
Output is correct |
13 |
Incorrect |
1 ms |
328 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 |
324 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Incorrect |
20 ms |
2640 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |