Submission #344158

#TimeUsernameProblemLanguageResultExecution timeMemory
344158IZhO_2021_I_want_SilverLongest beautiful sequence (IZhO17_subsequence)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <algorithm> #include <vector> #include <cassert> using namespace std; typedef pair <int, int> pii; #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define pb push_back #define F first #define S second const int N = 1e5 + 5; const int MX = (1 << 8) + 5; int n, a[N], k[N], pre[N], dp[N], pos[N]; vector <int> vec; void solve() { cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } for (int i = 1; i <= n; ++i) { cin >> k[i]; } int ans = 0, posans = 0; for(int i = 1; i <= n; ++i) { int mx = 0; if(n <= 5000) { for(int j = 1; j < i; ++j) { if(__builtin_popcount((a[i] & a[j])) == k[i]) { if(mx < dp[j]) { mx = dp[j]; p[i] = j; } } } } else { for(int j = 0; j < (1 << 8); ++j) { for(int posj : pos[j]) { if(__builtin_popcount((a[i] & j)) == k[i]) { if(mx < dp[posj]) { mx = dp[posj]; p[i] = posj; } } } } pos[a[i]].pb(i); } dp[i] = mx + 1; if(ans < dp[i]) { ans = dp[i]; posans = i; } } vector <int> vec; while(posans) {vec.pb(posans); posans = p[posans];} reverse(all(vec)); cout << ans <<'\n'; for(int it : vec) cout << it <<' '; return 0; } } int main () { ios_base::sync_with_stdio(false); cin.tie(NULL); int tests = 1; //cin >> tests; while (tests --) { solve(); } return 0; } /* Just Chalish! 4 1 2 3 4 10 0 1 0 2 8 9 20 0 5 5 3 5 3 5 10 1 20 1 20 */

Compilation message (stderr)

subsequence.cpp: In function 'void solve()':
subsequence.cpp:38:10: error: 'p' was not declared in this scope
   38 |          p[i] = j;
      |          ^
subsequence.cpp:44:25: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   44 |     for(int posj : pos[j]) {
      |                         ^
      |                         std::begin
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from subsequence.cpp:1:
/usr/include/c++/9/bits/range_access.h:105:37: note: 'std::begin' declared here
  105 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
      |                                     ^~~~~
subsequence.cpp:44:25: error: 'end' was not declared in this scope; did you mean 'std::end'?
   44 |     for(int posj : pos[j]) {
      |                         ^
      |                         std::end
In file included from /usr/include/c++/9/string:54,
                 from /usr/include/c++/9/bits/locale_classes.h:40,
                 from /usr/include/c++/9/bits/ios_base.h:41,
                 from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from subsequence.cpp:1:
/usr/include/c++/9/bits/range_access.h:107:37: note: 'std::end' declared here
  107 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
      |                                     ^~~
subsequence.cpp:48:11: error: 'p' was not declared in this scope
   48 |           p[i] = posj;
      |           ^
subsequence.cpp:12:12: error: request for member 'push_back' in 'pos[a[i]]', which is of non-class type 'int'
   12 | #define pb push_back
      |            ^~~~~~~~~
subsequence.cpp:53:14: note: in expansion of macro 'pb'
   53 |    pos[a[i]].pb(i);
      |              ^~
subsequence.cpp:62:42: error: 'p' was not declared in this scope; did you mean 'dp'?
   62 |  while(posans) {vec.pb(posans); posans = p[posans];}
      |                                          ^
      |                                          dp
subsequence.cpp:67:9: error: return-statement with a value, in function returning 'void' [-fpermissive]
   67 |  return 0;
      |         ^
subsequence.cpp: At global scope:
subsequence.cpp:69:1: error: expected declaration before '}' token
   69 | }
      | ^