Submission #502250

#TimeUsernameProblemLanguageResultExecution timeMemory
502250luka1234Longest beautiful sequence (IZhO17_subsequence)C++14
0 / 100
1 ms332 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; int n; int a[100001],b[100001]; int d[257]; vector<int> ans[257]; int main(){ cin>>n; for(int k=1;k<=n;k++) cin>>a[k]; for(int k=1;k<=n;k++) cin>>b[k]; d[a[1]]=1; ans[a[1]].push_back(1); for(int k=2;k<=n;k++){ int cnt=0; int ind=0; for(int i=0;i<256;i++){ int f=a[k]&i; f=__builtin_popcount(f); if(f==b[k]){ if(d[i]+1>cnt){ cnt=d[i]+1; ind=i; } } } if(d[a[k]]<cnt){ d[a[k]]=cnt; ans[a[k]]=ans[ind]; ans[a[k]].push_back(k); } } int mx=0; int ind=0; for(int k=0;k<256;k++){ if(d[k]>mx){ mx=d[k]; ind=k; } } cout<<mx<<"\n"; for(int k=0;k<ans[ind].size();k++) cout<<ans[ind][k]<<' '; return 0; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:46:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |  for(int k=0;k<ans[ind].size();k++)
      |              ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...