# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89660 | antimirage | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 11 ms | 8568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define mk make_pair
#define pb emplace_back
#define all(s) s.begin(), s.end()
using namespace std;
const int N = 1e5 + 5;
int dp[11][1025][1025], p[N], n, ar[N], k[N], ans, ind[11][1025][1025], last;
vector <int> path;
main()
{
cin >> n;
for (int i = 1; i <= n; i++)
scanf("%d", &ar[i]);
for (int i = 1; i <= n; i++)
scanf("%d", &k[i]);
for (int i = 1; i <= n; i++)
{
int pref = (ar[i] >> 10), suf = ar[i] % 1024, res = 0;
for (int j = 0; j < 1024; j++)
{
if ( __builtin_popcount( j & suf ) > k[i] ) continue;
if ( dp[ k[i] - __builtin_popcount( j & suf ) ][pref][j] > res )
{
res = dp[ k[i] - __builtin_popcount( j & suf ) ][pref][j];
p[i] = ind[ k[i] - __builtin_popcount( j & suf ) ][pref][j];
}
}
res++;
if (res > ans){
ans = res;
last = i;
}
for (int j = 0; j < 1024; j++){
if (res > dp[__builtin_popcount(pref & j) ][j][suf])
{
dp[__builtin_popcount(pref & j) ][j][suf] = res;
ind[__builtin_popcount(pref & j) ][j][suf] = i;
}
}
}
cout << ans << endl;
while (ans){
path.push_back( last );
last = p[last];
ans--;
}
reverse(all(path));
for (auto it : path)
printf("%d ", it);
}
/**
4
1 2 3 4
10 0 1 0
5
5 3 5 3 5
10 1 20 1 20
**/
컴파일 시 표준 에러 (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... |