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

#TimeUsernameProblemLanguageResultExecution timeMemory
659232ono_de206Longest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
3757 ms97544 KiB
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<set> using namespace std; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second //#define int long long template<typename T> void mxx(T &a, T b){if(b>a) a=b;} template<typename T> void mnn(T &a, T b){if(b<a) a=b;} const int mxn=11,mxxa=1e5+10; pair<int,int> dp[1<<mxn][1<<mxn][mxn]; int par[mxxa],dd[mxxa]; int bb[1<<mxn][1<<mxn]; int a[mxxa],k[mxxa]; void build(){ for(int i=0; i<(1<<10); i++){ for(int j=0; j<(1<<10); j++){ bb[i][j]=__builtin_popcount(i&j); } } } signed main(){ fast; int n; cin>>n; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) cin>>k[i]; pair<int,int> ans=make_pair(0,0); for(int i=1; i<=n; i++){ int l=(a[i]>>10); int r=(a[i]^(l<<10)); auto mx=make_pair(0,0); for(int j=0; j<(1<<10); j++){ int cnt=k[i] - __builtin_popcount(j&l); if(cnt<0 || cnt>10) continue; mxx(mx,dp[j][r][cnt]); } par[i]=mx.ss; mx.ff++; mx.ss=i; mxx(ans,mx); for(int j=0; j<(1<<10); j++){ int cnt=__builtin_popcount(j&r); mxx(dp[l][j][cnt],mx); } } cout<<ans.ff<<'\n'; vector<int> tmp; for(int i=0; i<ans.ff; i++){ tmp.pb(ans.ss); ans.ss=par[ans.ss]; } sort(all(tmp)); for(int x : tmp){ cout<<x<<' '; } cout<<'\n'; 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...