이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,f[100009],k[100009],dp[100009],pas1,pas2,nxt[100009],ka[1009],kaa[1009];
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;
if(dp[b]<ka[f[b]]){
dp[b]=ka[f[b]];
nxt[b]=kaa[f[b]];
}
for(c=0; c<(1<<8); c++){
if(__builtin_popcount(f[b]&c)==k[b]&&ka[c]<dp[b]+1){
ka[c]=dp[b]+1;
kaa[c]=b;
}
}
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... |