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

#TimeUsernameProblemLanguageResultExecution timeMemory
314283kshitij_sodaniLongest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
5433 ms93524 KiB
#include <bits/stdc++.h> using namespace std; typedef long long llo; #define mp make_pair #define pb push_back #define a first #define b second //#define endl '\n' #define cot __builtin_popcount int it[100001]; int kk[100001]; int n; int dp[1024][1024][11]; int back[1024][1024][11]; int back2[100001]; int dp2[100001]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for(int i=0;i<n;i++){ cin>>it[i]; } for(int i=0;i<n;i++){ cin>>kk[i]; } for(int i=0;i<n;i++){ int aa=1; int val=it[i]&1023; int val2=(it[i]-val)/1024; //cout<<val<<":"<<val2<<endl; back2[i]=-1; for(int j=0;j<1024;j++){ if(cot(j&val)>kk[i]){ continue; } if(kk[i]-cot(j&val)>10){ continue; } if(dp[j][val2][kk[i]-cot(j&val)]+1>aa){ back2[i]=back[j][val2][kk[i]-cot(j&val)]; } aa=max(aa,dp[j][val2][kk[i]-cot(j&val)]+1); } // cout<<aa<<":"<<endl; dp2[i]=aa; //ans=max(ans,aa); for(int j=0;j<1024;j++){ if(aa>dp[val][j][cot(j&val2)]){ back[val][j][cot(j&val2)]=i; } dp[val][j][cot(j&val2)]=max(dp[val][j][cot(j&val2)],aa); } } int ma=0; int ind=-1; for(int i=0;i<n;i++){ if(dp2[i]>ma){ ma=dp2[i]; ind=i; } } vector<int> ans; ans.pb(ind); while(true){ ind=back2[ind]; if(ind==-1){ break; } ans.pb(ind); } cout<<ma<<endl; while(ans.size()){ cout<<ans.back()+1<<" "; ans.pop_back(); } cout<<endl; 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...