제출 #502246

#제출 시각아이디문제언어결과실행 시간메모리
502246luka1234Longest beautiful sequence (IZhO17_subsequence)C++14
23 / 100
6074 ms160636 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 dp[100001]; vector<int> ans[100001]; int main(){ cin>>n; for(int k=1;k<=n;k++) cin>>a[k]; for(int k=1;k<=n;k++) cin>>b[k]; dp[1]=1; ans[1].push_back(1); for(int k=2;k<=n;k++){ int cnt=1; int indexi=k; for(int i=k-1;i>=1;i--){ int f=a[k]&a[i]; f=__builtin_popcount(f); if(f==b[k]){ if(dp[i]+1>cnt){ cnt=dp[i]+1; indexi=i; } } } dp[k]=cnt; if(indexi==k) ans[k].push_back(k); else{ ans[k]=ans[indexi]; ans[k].push_back(k); } } int mx=0; int ind=0; for(int k=1;k<=n;k++){ if(dp[k]>mx){ mx=dp[k]; ind=k; } } cout<<mx<<"\n"; for(int k=0;k<ans[ind].size();k++) cout<<ans[ind][k]<<' '; return 0; }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:48:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |  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...