이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//
//  main1.cpp
//  problem1
//
//  Created by Mohammad Bashkail on 20/10/1445 AH.
//
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
using ll = long long;
#define pb push_back
#define pF first
#define pS second
#define SP <<" "<<
vector<bitset<21>> a;
ll k[5050], dp[5050], par[5050];
int main() {
    ios::sync_with_stdio(0);cout.tie(0); cin.tie(0);
    ll n;
    cin>>n;
    for (int i=0; i<n; i++) {
        ll x;
        cin>>x;
        bitset<21> b(x);
        a.pb(b);
    }
    for (int i=0; i<n; i++) cin>>k[i];
    
    fill(dp, dp+n, 1);
    fill(par, par+n, -1);
    for (int i=0; i<n; i++) {
        for (int j=i-1; j>=0; j--) {
            bitset<21> b(a[i] & a[j]);
            if (b.count() == k[i]) {
                if (dp[j]+1 > dp[i]) {
                    par[i] = j;
                    dp[i] = dp[j]+1;
                }
            }
        }
    }
    pair<ll,ll> mx = {-1, 0};
    for (int i=0; i<n; i++) {
        if (dp[i] > mx.pF) {
            mx = {dp[i], i};
        }
    }
    cout << mx.pF << endl;
    ll i = mx.pS;
    vector<ll> ans;
    while(i != -1) {
        ans.pb(i);
        i = par[i];
    }
    reverse(ans.begin(), ans.end());
    for (ll i : ans) cout << i+1 << " ";
}
컴파일 시 표준 에러 (stderr) 메시지
subsequence.cpp: In function 'int main()':
subsequence.cpp:36:27: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   36 |             if (b.count() == k[i]) {
      |                 ~~~~~~~~~~^~~~~~~| # | 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... |