| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 314928 | dolphingarlic | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 5975 ms | 92760 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define popcnt __builtin_popcount
using namespace std;
const int FM = (1 << 20) - 1, HM = (1 << 10) - 1, N = 1e5 + 1;
int a[N], k[N];
pair<int, int> dp[HM + 1][HM + 1][11], ans[N];
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", a + i);
for (int i = 1; i <= n; i++) {
scanf("%d", k + i);
pair<int, int> best = {0, 0};
for (int j = 0; j < (1 << 10); j++)
if (popcnt(a[i] & j) <= k[i] && k[i] - popcnt(a[i] & j) <= 10)
best = max(best, dp[j][a[i] >> 10][k[i] - popcnt(a[i] & j)]);
best.first++;
ans[i] = best;
for (int j = 0; j < (1 << 10); j++) {
int cnt = popcnt((a[i] >> 10) & j);
dp[a[i] & HM][j][cnt] = max(dp[a[i] & HM][j][cnt], {best.first, i});
}
}
int idx = max_element(ans + 1, ans + n + 1) - ans;
printf("%d\n", ans[idx].first);
stack<int> seq;
while (idx) {
seq.push(idx);
idx = ans[idx].second;
}
while (seq.size()) {
printf("%d ", seq.top());
seq.pop();
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
