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

#TimeUsernameProblemLanguageResultExecution timeMemory
289767HynDufLongest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
3054 ms90104 KiB
#include <bits/stdc++.h> #define task "S" #define all(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i <= (r); ++i) #define Rep(i, r, l) for (int i = (r); i >= (l); --i) #define DB(X) { cerr << #X << " = " << (X) << '\n'; } #define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; } #define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; } #define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; } #define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';} #define SZ(x) ((int)(x).size()) #define pb push_back #define eb emplace_back #define pf push_front #define F first #define S second #define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a)); #define next ___next #define prev ___prev #define y1 ___y1 #define left ___left #define right ___right #define y0 ___y0 #define div ___div #define j0 ___j0 #define jn ___jn using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ll> vl; const int N = 1e5 + 2; int n, a[N], maxDp[1 << 10][11][1 << 10], id[1 << 10][11][1 << 10], k[N], dp[N], track[N], cnt[1 << 10]; int M = (1 << 10) - 1; int main() { #ifdef HynDuf freopen(task".in", "r", stdin); //freopen(task".out", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif cin >> n; rep(i, 1, n) cin >> a[i]; rep(i, 1, n) cin >> k[i]; rep(i, 1, M) cnt[i] = __builtin_popcount(i); rep(i, 1, n) { dp[i] = 1; int RofAi = M & a[i], LofAi = M & (a[i] >> 10); rep(R, 0, M) { int numk = cnt[R & RofAi]; if (k[i] - numk <= 10 && k[i] >= numk && dp[i] < maxDp[R][k[i] - numk][LofAi] + 1) { track[i] = id[R][k[i] - numk][LofAi]; dp[i] = maxDp[R][k[i] - numk][LofAi] + 1; } } rep(L, 0, M) { int num = cnt[L & LofAi]; if (maxDp[RofAi][num][L] < dp[i]) { maxDp[RofAi][num][L] = dp[i]; id[RofAi][num][L] = i; } } } vi res; int ans = 0, ansi = 0; rep(i, 1, n) if (ans < dp[i]) ans = dp[i], ansi = i; while (ansi) { res.eb(ansi); ansi = track[ansi]; } cout << ans << '\n'; Rep(i, SZ(res) - 1, 0) cout << res[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...