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

#TimeUsernameProblemLanguageResultExecution timeMemory
198834MetBLongest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
3564 ms93364 KiB
#include <bits/stdc++.h> #define N 1000001 using namespace std; typedef long long ll; const ll INF = 1e18, MOD = 1e9 + 7, MOD2 = 1e6 + 3; int d[1 << 10][1 << 10][11], p[1 << 10][1 << 10][11], pc[1 << 20]; int a[N], k[N], n, bm = (1 << 10) - 1, ans, par[N], ind; int main () { cin >> n; for (int i = 0; i < (1 << 10); i++) pc[i] = __builtin_popcount (i); memset (p, -1, sizeof (p)); for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> k[i]; } for (int i = 0; i < n; i++) { int x = 0; par[i] = -1; for (int j = 0; j < (1 << 10); j++) { int l = k[i] - pc[j & (a[i] >> 10)]; if (l < 0 || l > 10) continue; if (x < d[j][a[i] & bm][l]) { par[i] = p[j][a[i] & bm][l]; x = d[j][a[i] & bm][l]; } } x++; for (int j = 0; j < (1 << 10); j++) { int& c = d[a[i] >> 10][j][pc[j & a[i]]]; if (x > c) { c = x; p[a[i] >> 10][j][pc[j & a[i]]] = i; } } if (x > ans) { ans = x; ind = i; } } vector <int> v; cout << ans << endl; while (ind != -1) { v.push_back (ind + 1); ind = par[ind]; } reverse (v.begin(), v.end()); for (int i : v) cout << i << ' '; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...