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

#TimeUsernameProblemLanguageResultExecution timeMemory
519169nickmet2004Longest beautiful sequence (IZhO17_subsequence)C++11
100 / 100
2836 ms93192 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 5 , M = 10; int n,a[N] , k[N]; int dp[1028][1028][M+1] , p[1028][1028][M+1], P[N] , mx , id; int main (){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i= 0; i< n; ++i) cin >> a[i]; for(int i = 0; i< n; ++i)cin >> k[i]; memset(P , -1 , sizeof(P)); for(int i =0; i < n; ++i){ int A = a[i] >> M , B = a[i] & ((1<<M) - 1) , ans = 0; for(int l =0; l < (1<<M); ++l){ int y = k[i] - __builtin_popcount(l & A); if(y < 0 || y > 10) continue; if(dp[l][B][y] > ans){ ans = dp[l][B][y]; P[i] = p[l][B][y]; } } ans++; if(ans > mx)mx = ans, id = i; for(int r= 0; r< (1<<M);++r){ int y = __builtin_popcount(B & r); if(dp[A][r][y] < ans){ dp[A][r][y] = ans; p[A][r][y] = i; } } } vector<int> X; while(1){ X.emplace_back(id); id = P[id]; if(id == -1)break; } reverse(X.begin() , X.end()); cout << X.size() << endl; for(int x : X)cout << x+1 << " "; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...