| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 94416 | Kastanda | Longest beautiful sequence (IZhO17_subsequence) | C++11 | 6070 ms | 1888 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
using namespace std;
const int N = 100005;
int n, ts, A[N], K[N], dp[N], P[N], R[N];
int main()
{
    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]);
    int nw = 0;
    for (int i = 1; i <= n; i++)
    {
        int k = K[i];
        int &Mx = dp[i], &a = A[i], &p = P[i];
        for (int j = 1; j < i; j++)
            if (__builtin_popcount(a & A[j]) == k && Mx < dp[j])
                {Mx = dp[j]; p = j;}
        dp[i] ++;
        if (dp[i] > dp[nw])
            nw = i;
    }
    while (nw)
    {
        R[ts ++] = nw;
        nw = P[nw];
    }
    printf("%d\n", ts);
    for (int i = ts - 1; ~i; i--)
        printf("%d ", R[i]);
    return 0;
}
Compilation message (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... | ||||
