제출 #1073527

#제출 시각아이디문제언어결과실행 시간메모리
1073527Hugo1729Longest beautiful sequence (IZhO17_subsequence)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<int> a(n),k(n); for(int i=0;i<n;i++)cin >> a[i]; for(int i=0;i<n;i++)cin >> k[i]; vector<int> dp(n,1); vector<int> prev(n,-1); int best=-1,best_pos=-1; for(int i=1;i<n;i++){ for(int j=0;j<i;j++){ if(__popcount(a[i]&a[j])==k[i]){ if(dp[i]<dp[j]+1){ dp[i]=dp[j]+1; prev[i]=j; } } } if(best<dp[i]){ best=dp[i]; best_pos=i; } } vector<int> out; cout << best << '\n'; for(int i=0;i<best;i++){ out.push_back(best_pos); best_pos = prev[best_pos]; } for(int i=best-1;i>=0;i--)cout << out[i]+1 <<' '; cout << '\n'; return 0; }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:20:16: error: '__popcount' was not declared in this scope
   20 |             if(__popcount(a[i]&a[j])==k[i]){
      |                ^~~~~~~~~~