(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 #334159

#TimeUsernameProblemLanguageResultExecution timeMemory
334159tengiz05Longest beautiful sequence (IZhO17_subsequence)C++17
100 / 100
5630 ms48492 KiB
#include <bits/stdc++.h> using namespace std; #define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); #define all(x) (x).begin(), (x).end() #define count __builtin_popcount #define pb push_back const int N = 1e5+2; int a[N], n, m, k[N]; int dp[N]; int par[N]; int f[1024][1024][11]; void solve(int test_case){ int i, j; cin >> n; for(i=1;i<=n;i++){ cin >> a[i]; } for(i=1;i<=n;i++){ cin >> k[i]; } vector<int> ans; for(i=1;i<=n;i++){ int l = a[i]>>10; int r = a[i]&1023; int best = 0; for(j=0;j<1024;j++){ int tmp = count(j&r); tmp = k[i]-tmp; if(tmp < 0 || tmp > 10)continue; if(dp[best] < dp[f[l][j][tmp]])best = f[l][j][tmp]; } dp[i] = dp[best]+1; par[i] = best; for(j=0;j<1024;j++){ int tmp = count(l&j); if(dp[i] > dp[f[j][r][tmp]])f[j][r][tmp] = i; } } m = 1; for(i=2;i<=n;i++)if(dp[i] > dp[m])m = i; cout << dp[m] << '\n'; while(m>0){ ans.pb(m); m = par[m]; } reverse(all(ans)); for(auto x : ans)cout << x << ' '; return; } signed main(){ FASTIO; #define MULTITEST 0 #if MULTITEST int ___T; cin >> ___T; for(int T_CASE = 1; T_CASE <= ___T; T_CASE++) solve(T_CASE); #else solve(1); #endif 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...