| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1007341 | Essa2006 | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 3729 ms | 174164 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mdo (ll)(1000000007)
 
array<int, 2> dp[1024][1024][21];
 
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
 
 
 
    int n;
    cin >> n;
 
    vector<int> A(n), K(n);
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> K[i];
    }
 
    int ans = 0, ind = 0;
    vector<int> Prv(n, -1);
    for (int i = 0; i < n; i++) {
        int low = 0, up = 0;
        for (int j = 0; j < 10; j++) {
            low += ((1 << j) & A[i]);
        }
        for (int j = 10; j < 20; j++) {
            if ((1 << j) & A[i]) {
                up += (1 << (j - 10));
            }
        }
 
        int res = 1;
        for (int x = 0; x < (1 << 10); x++) {
            if (K[i] - __builtin_popcount(x & low) < 0) {
                continue;
            }
            if (dp[x][up][K[i] - __builtin_popcount(x & low)][0] + 1 > res) {
                res = dp[x][up][K[i] - __builtin_popcount(x & low)][0] + 1;
                Prv[i] = dp[x][up][K[i] - __builtin_popcount(x & low)][1];
            }
        }
 
        if (res > ans) {
            ind = i, ans = res;
        }
        for (int x = 0; x < (1 << 10); x++) {
            if (res > dp[low][x][__builtin_popcount(x & up)][0]) {
                dp[low][x][__builtin_popcount(x & up)][0] = res;
                dp[low][x][__builtin_popcount(x & up)][1] = i;
            }
        }
 
    }
 
 
    vector<int> Ans;
    Ans.push_back(ind);
    while (Prv[ind] != -1) {
        ind = Prv[ind];
        Ans.push_back(ind);
    }
 
    cout << Ans.size() << endl;
    reverse(all(Ans));
    for (int i = 0; i < Ans.size(); i++) {
        cout << Ans[i] + 1 << ' ';
    }
}
컴파일 시 표준 에러 (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... | ||||
