(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #85823

#제출 시각아이디문제언어결과실행 시간메모리
85823ToadDaveskiLongest beautiful sequence (IZhO17_subsequence)C++11
100 / 100
4664 ms228108 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll a[100001],k[100001],kolb[(1<<11)],dp[21][(1<<11)][(1<<11)],pr[100001],nom[21][(1<<11)][(1<<11)]; deque <ll> answer; int main() { ll n,m,i,j,fin=-1,mdp=-1; cin>>n; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=n;i++) cin>>k[i]; for(i=1;i<=(1<<10);i++) kolb[i]= __builtin_popcount(i); for(i=1;i<=n;i++) { ll x=(a[i]>>10); ll y=a[i]-(x<<10); pr[i]=i; ll ans=1; for(j=0;j<=(1<<10);j++) { ll ob=kolb[y&j]; if (ob<=k[i] && k[i]-ob<=10 && dp[k[i]-ob][j][x]+1>ans) { //cout<<i<<"="<<j<<" "<<x<<" "<<nom[k[i]-ob][j][x]<<" "<<dp[k[i]-ob][j][x]<<" "; ans=dp[k[i]-ob][j][x]+1; pr[i]=nom[k[i]-ob][j][x]; } } if (mdp<ans) { mdp=ans; fin=i; } for(j=0;j<=(1<<10);j++) { ll ob=kolb[x&j]; if (dp[ob][y][j]<ans) { dp[ob][y][j]=ans; nom[ob][y][j]=i; } } //cout<<ans<<endl; } //cout<<endl; // cout<<pr[2]<<endl; while(pr[fin]!=fin) { answer.push_front(fin); fin=pr[fin]; } answer.push_front(fin); cout<<answer.size()<<endl; for(ll toad : answer) cout<<toad<<" "; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

subsequence.cpp: In function 'int main()':
subsequence.cpp:8:10: warning: unused variable 'm' [-Wunused-variable]
     ll n,m,i,j,fin=-1,mdp=-1;
          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...