| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 35049 | model_code | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 6000 ms | 8068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
const int maxn = (int)(1e5 + 111);
int n, a[maxn], k[maxn], dp[maxn], p[maxn], cnt[(1 << 20) + 111];
int b[maxn], m;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; ++i)
scanf("%d", &a[i]);
for (int i = 0; i < n; ++i)
scanf("%d", &k[i]);
for (int i = 0; i < n; ++i) {
dp[i] = 1;
p[i] = -1;
}
for(int i = 0; i < (1<<20); i++)
cnt[i] = __builtin_popcount(i);
int q = 0, ans = 0;
for (int i = 0; i < n; ++i)
for (int j = 0; j < i; ++j)
if (cnt[a[j] & a[i]] == k[i] && dp[i] < dp[j] + 1) {
dp[i] = dp[j] + 1;
p[i] = j;
}
for (int i = 0; i < n; ++i)
if (dp[i] > ans) {
ans = dp[i];
q = i;
}
while (q != -1) {
b[m++] = q + 1;
q = p[q];
}
reverse(b, b + m);
printf("%d\n", m);
for (int i = 0; i < m; ++i)
printf("%d ", b[i]);
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... | ||||
