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>
using namespace std;
int a,b,c,d,e,f[100009],k[100009],dp[100009],pas1,pas2,nxt[100009];
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(b=1; b<=a; b++) cin>>f[b];
for(b=1; b<=a; b++) cin>>k[b];
for(b=a; b>=1; b--){
dp[b]=1;
for(c=b+1; c<=a; c++){
if(__builtin_popcount(f[b]&f[c])==k[c]&&dp[b]<dp[c]+1){
dp[b]=dp[c]+1;
nxt[b]=c;
}
}
if(pas1<dp[b]){
pas1=dp[b];
pas2=b;
}
}
cout<<pas1<<endl;
while(pas2!=0){
cout<<pas2<<" ";
pas2=nxt[pas2];
}
return 0;
}
# | 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... |