이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int nx=1e5+5, kx=(1<<10);
int n, a[nx], k[nx];
pair<int, int> dp[kx][kx][11], res, p[nx];
vector<int> ans(1);
int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i], p[i]={1, INT_MAX};
    for (int i=1; i<=n; i++) cin>>k[i];
    for (int i=1; i<=n; i++)
    {
        int l=(a[i]/kx), r=a[i]&(kx-1);
        for (int j=0; j<kx; j++)
        {
            int left=(k[i]-(__builtin_popcount(j&l)));
            if (0<=left&&left<=10) p[i]=max(p[i], {dp[j][r][left].first+1, dp[j][r][left].second});
        }
        for (int j=0; j<kx; j++)
        {
            dp[l][j][__builtin_popcount(j&r)]=max(dp[l][j][__builtin_popcount(j&r)], {p[i].first, i});
        }
        if (p[i].first>res.first) res=p[i], ans[0]=i;
    }
    cout<<res.first<<'\n';
    while (res.second!=INT_MAX) ans.push_back(res.second), res=p[res.second];
    reverse(ans.begin(), ans.end());
    for (auto x:ans) cout<<x<<' ';
}
| # | 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... |