(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #346740

#TimeUsernameProblemLanguageResultExecution timeMemory
346740asdfgod69Longest beautiful sequence (IZhO17_subsequence)C++14
0 / 100
1 ms512 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; using ll = long long; using pii = pair<int, int>; const int MN = 1e5 + 5; int N, a[MN], k[MN], dp[MN], last[MN], idx[256]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> N; for (int i = 1; i <= N; i++) cin >> a[i]; for (int i = 1; i <= N; i++) cin >> k[i]; int mx = 0, at = 0; for (int i = 1; i <= N; i++) { dp[i] = 1; for (int msk = 0; msk < 256; msk++) { if (__builtin_popcount(msk & a[i]) == k[i] && dp[i] < dp[idx[msk]] + 1) { dp[i] = dp[idx[msk]] + 1; last[i] = idx[msk]; } } if (dp[i] > dp[idx[a[i]]]) idx[a[i]] = i; if (dp[i] > mx) mx = dp[i], at = i; } cout << mx << '\n'; vector<int> v; while (at) { v.push_back(at); at = last[at]; } reverse(all(v)); for (int i : v) cout << i << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...