#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
signed main(){
fastio
int n,m;
cin >> n >> m;
vector<int> v(m);
for(int i = 0;i < m;i++){
int q;
cin >> q;
int tmp = 0;
for(int j = 0;j < q;j++){
int x;
cin >> x;
x--;
tmp ^= (1LL<<x);
}
v[i] = tmp;
}
vector<int> ans;
for(int i = 0;i <= m;i++){
ans.push_back(m+1);
}
for(int i = 0;i < (1<<m);i++){
vector<int> tmp;
int now = (1LL<<n)-1;
for(int j = 0;j < m;j++){
if(i&(1LL<<j)){
now ^= v[j];
tmp.push_back(j);
}
}
if(now==0){
int sz = min(ans.size(),tmp.size());
if(ans.size() > tmp.size()) ans = tmp;
else if(ans.size()==tmp.size()){
for(int j = 0;j < sz;j++){
if(ans[j]>tmp[j]){
ans = tmp;
break;
}else if(ans[j]<tmp[j]){
break;
}
}
}
}
}
cout << ans.size() << "\n";
for(auto x : ans) cout << x+1 << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
204 KB |
Output is correct |
2 |
Correct |
63 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
72 ms |
292 KB |
Output is correct |
5 |
Correct |
59 ms |
304 KB |
Output is correct |
6 |
Correct |
73 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
204 KB |
Output is correct |
2 |
Correct |
63 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
72 ms |
292 KB |
Output is correct |
5 |
Correct |
59 ms |
304 KB |
Output is correct |
6 |
Correct |
73 ms |
296 KB |
Output is correct |
7 |
Correct |
239 ms |
292 KB |
Output is correct |
8 |
Correct |
480 ms |
292 KB |
Output is correct |
9 |
Correct |
497 ms |
288 KB |
Output is correct |
10 |
Correct |
462 ms |
288 KB |
Output is correct |
11 |
Correct |
427 ms |
288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
204 KB |
Output is correct |
2 |
Correct |
63 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
72 ms |
292 KB |
Output is correct |
5 |
Correct |
59 ms |
304 KB |
Output is correct |
6 |
Correct |
73 ms |
296 KB |
Output is correct |
7 |
Correct |
239 ms |
292 KB |
Output is correct |
8 |
Correct |
480 ms |
292 KB |
Output is correct |
9 |
Correct |
497 ms |
288 KB |
Output is correct |
10 |
Correct |
462 ms |
288 KB |
Output is correct |
11 |
Correct |
427 ms |
288 KB |
Output is correct |
12 |
Correct |
517 ms |
292 KB |
Output is correct |
13 |
Execution timed out |
940 ms |
304 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
204 KB |
Output is correct |
2 |
Correct |
63 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
72 ms |
292 KB |
Output is correct |
5 |
Correct |
59 ms |
304 KB |
Output is correct |
6 |
Correct |
73 ms |
296 KB |
Output is correct |
7 |
Correct |
239 ms |
292 KB |
Output is correct |
8 |
Correct |
480 ms |
292 KB |
Output is correct |
9 |
Correct |
497 ms |
288 KB |
Output is correct |
10 |
Correct |
462 ms |
288 KB |
Output is correct |
11 |
Correct |
427 ms |
288 KB |
Output is correct |
12 |
Correct |
517 ms |
292 KB |
Output is correct |
13 |
Execution timed out |
940 ms |
304 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |