# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
80848 | farukkastamonuda | Norela (info1cup18_norela) | C++14 | 88 ms | 804 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long
#define inf 1000000000
#define md 1000000007
#define li 2005
#define mp make_pair
#define pb push_back
using namespace std;
int n, m, x, y;
lo int ans, gg, ind[80];
lo int bet(lo int a, lo int b){
if(__builtin_popcount(a) < __builtin_popcount(b)) return a;
if(__builtin_popcount(a) > __builtin_popcount(b)) return b;
for(int i = 0;i < m; i ++){
int x = a&(1 << i);
int y = b&(1 << i);
if(x < y) return b;
if(y < x) return a;
}
return a;
}
void dfs(int node, lo int msk, lo int ste){
if(msk == gg){
ans=bet(ans, ste);
return ;
}
if(node == m + 1) return ;
dfs(node + 1, msk ^ ind[node], ste ^ (1 << (node - 1)));
dfs(node + 1, msk, ste);
}
int main(){
scanf("%d %d", &n, &m);
gg = (1LL << n) - 1;
ans = (1LL << m) - 1;
for(int i = 1; i <= m; i ++){
scanf("%d", &x);
for(int j = 1;j <= x; j ++){
scanf("%d", &y);
y--;
ind[i] ^= (1LL<<y);
}
}
dfs(1, 0, 0);
printf("%d\n", __builtin_popcount(ans));
for(int i = 0; i < m; i ++){
if(ans&(1 << i)) printf("%d ", i + 1);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |