Submission #939743

#TimeUsernameProblemLanguageResultExecution timeMemory
939743ifateenLongest beautiful sequence (IZhO17_subsequence)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; bool ckmax(int& a, int b) { if (a < b) return a = b, true; return false; } const int MAXN = 2001; int dp[MAXN], prv[MAXN], a[MAXN], k[MAXN]; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; dp[i] = 1; prv[i] = i; } for (int i = 0; i < n; i++) { cin >> k[i]; } for (int i = 1; i < n; i++) for (int j = 0; j < i; j++) if (__builtin_popcount(a[i] & a[j]) == k[i] && ckmax(dp[i], 1 + dp[j])) prv[i] = j; int mx = max_element(dp, dp + n) - dp; vector<int> ans; ans.push_back(mx); while (mx != prv[mx]) { mx = prv[mx]; ans.push_back(mx); } reverse(begin(ans), end(ans)); cout << size(ans) << '\n'; for (auto& i : ans) cout << i + 1 << ' '; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:33:13: error: 'size' was not declared in this scope; did you mean 'dysize'?
   33 |     cout << size(ans) << '\n';
      |             ^~~~
      |             dysize