제출 #35280

#제출 시각아이디문제언어결과실행 시간메모리
35280dqhungdlLongest beautiful sequence (IZhO17_subsequence)C++14
23 / 100
69 ms3736 KiB
#include <bits/stdc++.h> using namespace std; int n,a[100005],b[100005],f[100005],Trace[100005]; vector<int> rs; void Sub1() { int res=0,id; for(int i=1; i<=n; i++) { f[i]=1; for(int j=1; j<i; j++) if(__builtin_popcount(a[i]&a[j])==b[i]&&f[i]<f[j]+1) { f[i]=f[j]+1; Trace[i]=j; } if(res<f[i]) { res=f[i]; id=i; } } while(id>0) { rs.push_back(id); id=Trace[id]; } cout<<rs.size()<<"\n"; for(int i=rs.size()-1;i>=0;i--) cout<<rs[i]<<' '; } int main() { ios_base::sync_with_stdio(false); //freopen("TEST.INP","r",stdin); cin>>n; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i++) cin>>b[i]; if(n<=5000) Sub1(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...