제출 #1289760

#제출 시각아이디문제언어결과실행 시간메모리
1289760erkamNorela (info1cup18_norela)C++20
0 / 100
1 ms332 KiB
#include <iostream> using namespace std; int n, m; long long ans; long long arr[25]; long long goal; void solve(int cur_index, long long cur_mask, int cur_ans) { if ((cur_mask ^ arr[cur_index]) == goal) { cur_ans += (1ll << (m-cur_index-1)); ans = max(ans, (long long)cur_ans); return; } if (cur_index == m-1) { return; } solve(cur_index + 1, cur_mask ^ arr[cur_index], cur_ans + (1ll << (m-cur_index-1))); solve(cur_index + 1, cur_mask, cur_ans); } int main() { cin >> n >> m; goal = (1ll << n) - 1; for(int i = 0; i < m; i++) { int q; cin >> q; for(int j = 0; j < q; j++) { int x; cin >> x; arr[i] += 1ll << (x-1); } } solve(0, 0, 0); cout << __builtin_popcountll(ans) << endl; for(int i = 1; i <= m; i++) { if (ans & (1ll << (m-i))) { cout << i << " "; } } cout << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...