제출 #1006621

#제출 시각아이디문제언어결과실행 시간메모리
1006621Essa2006Longest beautiful sequence (IZhO17_subsequence)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) int main() { ios_base::sync_with_stdio(0);cin.tie(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]; } int ans = 0; vector<array<int, 2>> dp(n); for (int i = 0; i < n; i++) { dp[i][0] = 1, dp[i][1] = -1; for (int j = 0; j < i; j++) { int res = (A[i] & A[j]); if (pop_count(res) == K[i]) { if (dp[j][0] + 1 > dp[i][0]) { dp[i][0] = dp[j][0] + 1; dp[i][1] = j; } } } if (dp[i][0] > dp[ans][0]) { ans = i; } } vector<int> Ans; Ans.push_back(ans + 1); while (dp[ans][1] != -1) { ans = dp[ans][1]; Ans.push_back(ans + 1); } reverse(all(Ans)); cout << Ans.size() << endl; for (int i = 0; i < Ans.size(); i++) { cout << Ans[i] << ' '; } }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:30:17: error: 'pop_count' was not declared in this scope
   30 |             if (pop_count(res) == K[i]) {
      |                 ^~~~~~~~~
subsequence.cpp:51:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |     for (int i = 0; i < Ans.size(); i++) {
      |                     ~~^~~~~~~~~~~~