제출 #1318952

#제출 시각아이디문제언어결과실행 시간메모리
1318952hssaan_arifNorela (info1cup18_norela)C++20
0 / 100
15 ms424 KiB
// #include <bits/stdc++.h> #include <iostream> #include <cmath> #include <algorithm> #include <map> #include <unordered_map> #include <vector> #include <iomanip> #include <string> #include <queue> #include <set> #include <deque> using namespace std; #define endl "\n" #define pb push_back #define int long long #define fi first #define se second const int N = 3e5 + 5, M = 1e9 + 7, LG = 20; int n , A[N] , x , sz , m; void solve(){ cin >> n >> m; for (int i=0 ; i<m ; i++){ cin >> sz; int u = 0; for (int j=0 ; j<sz ; j++){ cin >> x; u += (1<<(x-1)); // cout << x << ' '; } A[i] = u; // cout << A[i] << endl; } // int ans = 1e18; int h = 1e18; vector<int> f(n+10 , 1e18); for (int j=0 ; j<(1<<m) ; j++){ int k = 0 , cn = 0; for (int i=0 ; i<m ; i++){ if ((1<<i) & j){ k ^= A[i]; // cout << A[i] << ' '; cn++; } } if (k == (1<<n) - 1){ // cout << j << ' ' << cn << ' ' << k << endl; vector<int> g; for (int i=0 ; i<m ; i++){ if ((1<<i) & j){ g.pb(i+1); } } if (h > cn){ h = cn; swap(f,g); continue; } if (g < f && h==cn){ swap(g,f); } } } cout << f.size() << endl; for (int i : f) cout << i << ' '; cout << endl; } signed main(){ // freopen("" , "r" , stdin); // freopen("" , "w" , stdout); // cout << setprecision(30); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int ts = 1; // cin >> ts; while(ts--){ solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...