Submission #1006636

#TimeUsernameProblemLanguageResultExecution timeMemory
1006636SulALongest beautiful sequence (IZhO17_subsequence)C++17
7 / 100
5 ms452 KiB
#include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int a[n], k[n]; for (int& i : a) cin >> i; for (int& i : k) cin >> i; pair<int,vector<int>> ans = {0, {}}; for (int mask = 0; mask < 1 << n; mask++) { vector<int> S; for (int i = 0; i < n; i++) if (mask & (1 << i)) { S.push_back(i); } int l = S.size(); bool isB = true; for (int j = 1; j < l; j++) { if (__builtin_popcount(a[S[j]] & a[S[j-1]]) != k[S[j]]) isB = false; } if (isB) { ans = max(ans, {l, S}); } } cout << ans.first << "\n"; for (auto i : ans.second) cout << 1+i << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...