# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1124410 | votranngocvy | Longest beautiful sequence (IZhO17_subsequence) | C++20 | 4559 ms | 125816 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
const int N = 1e5 + 5;
int a[N],k[N],n;
namespace sub2 {
int dp[N],trace[N];
void solve() {
int ans = 0,cur = 0;
for (int i = 1; i <= n; i++) {
dp[i] = 1;
for (int j = 1; j < i; j++)
if (__builtin_popcount(a[i] & a[j]) == k[i] && dp[i] < dp[j] + 1) {
dp[i] = dp[j] + 1;
trace[i] = j;
}
if (dp[i] > ans) ans = dp[i],cur = i;
}
vector<int>vec;
for (int i = cur; i > 0; i = trace[i]) vec.push_back(i);
reverse(vec.begin(),vec.end());
cout << ans << "\n";
for (auto x: vec) cout << x << " ";
cout << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |