제출 #502237

#제출 시각아이디문제언어결과실행 시간메모리
502237luka1234Longest beautiful sequence (IZhO17_subsequence)C++14
7 / 100
1 ms432 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; int n; int a[16],b[16]; int main(){ cin>>n; for(int k=0;k<n;k++){ cin>>a[k]; } for(int k=0;k<n;k++){ cin>>b[k]; } bitset<32> btans; int ans=0; for(int k=1;k<(1<<n);k++){ bitset<32> bt=k; int cnt=0; int wina=0; int ind=0; for(int i=0;i<n;i++){ if(bt[i]==1){ cnt++; if(cnt==1){ wina=i; } if(cnt>1){ int f=a[i]&a[wina]; int r=__builtin_popcount(f); if(r!=b[i]){ ind=1; break; } wina=i; } } } if(ind==0&&cnt>ans){ ans=cnt; btans=bt; } } cout<<ans<<"\n"; for(int k=0;k<n;k++){ if(btans[k]==1) cout<<k+1<<' '; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...