이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "O3", "unroll-loops")
#pragma GCC target("popcnt", "avx2")
#define int long long
const int MAXM = 24;
const int MAXN = 60;
using namespace std;
long long v[MAXM];
int smaller(int mask1, int mask2){
int i;
for( i = 0; i < MAXN; i++ ){
if(((mask1 & (1 << i)) > 0) != ((mask2 & (1 << i)) > 0)){
if(mask1 & (1 << i))
return 1;
return 0;
}
}
return 0;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, q, bit, i;
long long rez, mask, cmask;
cin >> n >> m;
for( i = 0; i < m; i++ ){
cin >> q;
while(q--){
cin >> bit;
bit--;
v[i] |= (1 << bit);
}
}
cmask = 0;
for( mask = 0; mask < (1 << m); mask++ ){
rez = 0;
for( i = 0; i < m; i++ ){
if(mask & (1 << i)){
rez ^= v[i];
}
}
if(__builtin_popcount(rez) == n && (__builtin_popcount(mask) < __builtin_popcount(cmask) || cmask == 0)){
cmask = mask;
}
else if(__builtin_popcount(rez) == n && __builtin_popcount(mask) == __builtin_popcount(cmask) && smaller(mask, cmask))
cmask = mask;
}
cout << __builtin_popcount(cmask) << "\n";
for( i = 0; i < m; i++ ){
if(cmask & (1 << i))
cout << i + 1 << " ";
}
return 0;
}
# | 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... |