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

#TimeUsernameProblemLanguageResultExecution timeMemory
478048BackNoobLongest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
3034 ms102072 KiB
#include <bits/stdc++.h> #define ll long long #define fi first #define se second #define endl '\n' #define mask(i) (1LL << (i)) #define task "name" #define ull unsigned long long using namespace std; const ll mxN = 220797 + 7; const ll inf = 1e9 + 277; const ll mod = 2147483648; const ll infll = 1e18 + 7; const ll base = 307; template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } int a[mxN]; int k[mxN]; int pre[mxN]; int cntbit[(1 << 10) + 7]; pair<int , int> dp[(1 << 10) + 7][(1 << 10) + 7][12]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("task.inp" , "r" , stdin); //freopen("task.out" , "w" , stdout); int n; cin >> n; for(int i = 1 ; i <= n ; i++) cin >> a[i]; for(int i = 1 ; i <= n ; i++) cin >> k[i]; for(int mask = 0 ; mask < (1 << 10) ; mask++) cntbit[mask] = __builtin_popcount(mask); pair<int , int> ans = {0 , 0}; for(int i = 1 ; i <= n ; i++) { pair<int , int> tmp = {0 , 0}; int left = (a[i] & ((1 << 10) - 1)); for(int mask = 0 ; mask < (1 << 10) ; mask++) { int need = k[i] - cntbit[(a[i] >> 10) & mask]; if(need >= 0 && need <= 10) maximize(tmp , dp[left][mask][need]); } pre[i] = tmp.se; tmp.fi++; tmp.se = i; maximize(ans , tmp); for(int mask = 0 ; mask < (1 << 10) ; mask++) { maximize(dp[mask][a[i] >> 10][cntbit[mask & a[i]]] , tmp); } } cout << ans.fi << endl; vector<int> res; int x = ans.se; while(x != 0) { res.push_back(x); x = pre[x]; } reverse(res.begin() , res.end()); for(int i : res) 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...