# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173055 | juggernaut | Longest beautiful sequence (IZhO17_subsequence) | C++14 | 3493 ms | 83476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//Just try and the idea will come!
#include<bits/stdc++.h>
using namespace std;
int a[100001],k[100001],cnt[1025],dp[21][1025][1025],pos[21][1025][1025],path[100001],n,i,x,y,res,j,tmp,mx,ind;
vector<int>ans;
main(){
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%d",&a[i]);
for(i=1;i<=n;i++)scanf("%d",&k[i]);
for(i=1;i<1025;i++)cnt[i]=__builtin_popcount(i);
for(i=1;i<=n;i++){
x=(a[i]>>10);
y=a[i]-(x<<10);
path[i]=i;
res=1;
for(j=0;j<1025;j++){
tmp=cnt[j&y];
if(tmp<=k[i]&&k[i]-tmp<11&&dp[k[i]-tmp][j][x]+1>res){
res=dp[k[i]-tmp][j][x]+1;
path[i]=pos[k[i]-tmp][j][x];
}
}
if(res>mx){
mx=res;
ind=i;
}
for(j=0;j<1025;j++){
tmp=cnt[x&j];
if(dp[tmp][y][j]<res){
dp[tmp][y][j]=res;
pos[tmp][y][j]=i;
}
}
}
while(path[ind]!=ind){
ans.push_back(ind);
ind=path[ind];
}
ans.push_back(ind);
reverse(ans.begin(),ans.end());
printf("%d\n",(int)ans.size());
for(int to:ans)printf("%d ",to);
}
컴파일 시 표준 에러 (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... |