Submission #752178

#TimeUsernameProblemLanguageResultExecution timeMemory
752178Sam_a17Ancient Machine (JOI21_ancient_machine)C++17
Compilation error
0 ms0 KiB
#include "Anna.h" void Send(int a); void Anna(int N, std::vector<char> S) { Send(0); for(int i = 0; i < N; i++) { if(S[i] == 'X') { Send(0); } else if(S[i] == 'Y') { Send(1); Send(0); } else { Send(1); Send(1); Send(0); } } }
#include "Bruno.h" void Remove(int d); void Bruno(int N, int L, std::vector<int> A) { vector<int> a; for(int i = 0; i < L - 1; i++) { assert(A[i] == 0); int j = i + 1, cnt = 0; while(j < L && A[j] == 1) { j++, cnt++; } if(cnt == 0) { a.push_back(0); } else if(cnt == 1) { a.push_back(1); } else { a.push_back(2); } i = j - 1; } set<int> st[3]; auto dll = [&](int l, int r)-> void { for(int i = 0; i < 3; i++) { auto it = st[i].lower_bound(l); vector<int> to_del; while(it != st[i].end() && *it < r) { to_del.push_back(*it); it = next(it); } for(auto j: to_del) { Remove(j); st[i].erase(j); } } }; for (int i = 0; i < N; i++) { int ok = 0; if(a[i] == 2) { if(!st[1].empty() && !st[0].empty()) { auto itr = *st[1].rbegin(); auto itl = *st[0].begin(); if(itl < itr) { dll(itr + 1, i); itl = *st[0].rbegin(); dll(itl + 1, itr); // st[1].erase(prev(st[1].end())); Remove(itr); ok = 1; } } } st[a[i]].insert(i); } for(int i = 0; i < 3; i++) { for(auto j: st[i]) { Remove(j); } } }

Compilation message (stderr)

Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:5:3: error: 'vector' was not declared in this scope
    5 |   vector<int> a;
      |   ^~~~~~
Bruno.cpp:5:3: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from Bruno.h:1,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from Bruno.h:1,
                 from Bruno.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
Bruno.cpp:5:10: error: expected primary-expression before 'int'
    5 |   vector<int> a;
      |          ^~~
Bruno.cpp:7:5: error: 'assert' was not declared in this scope
    7 |     assert(A[i] == 0);
      |     ^~~~~~
Bruno.cpp:2:1: note: 'assert' is defined in header '<cassert>'; did you forget to '#include <cassert>'?
    1 | #include "Bruno.h"
  +++ |+#include <cassert>
    2 | void Remove(int d);
Bruno.cpp:15:7: error: 'a' was not declared in this scope
   15 |       a.push_back(0);
      |       ^
Bruno.cpp:17:7: error: 'a' was not declared in this scope
   17 |       a.push_back(1);
      |       ^
Bruno.cpp:19:7: error: 'a' was not declared in this scope
   19 |       a.push_back(2);
      |       ^
Bruno.cpp:25:3: error: 'set' was not declared in this scope
   25 |   set<int> st[3];
      |   ^~~
Bruno.cpp:25:7: error: expected primary-expression before 'int'
   25 |   set<int> st[3];
      |       ^~~
Bruno.cpp: In lambda function:
Bruno.cpp:29:17: error: 'st' was not declared in this scope; did you mean 'std'?
   29 |       auto it = st[i].lower_bound(l);
      |                 ^~
      |                 std
Bruno.cpp:30:14: error: expected primary-expression before 'int'
   30 |       vector<int> to_del;
      |              ^~~
Bruno.cpp:32:9: error: 'to_del' was not declared in this scope
   32 |         to_del.push_back(*it);
      |         ^~~~~~
Bruno.cpp:33:14: error: 'next' was not declared in this scope; did you mean 'std::next'?
   33 |         it = next(it);
      |              ^~~~
      |              std::next
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Bruno.h:1,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:213:5: note: 'std::next' declared here
  213 |     next(_InputIterator __x, typename
      |     ^~~~
Bruno.cpp:36:19: error: 'to_del' was not declared in this scope
   36 |       for(auto j: to_del) {
      |                   ^~~~~~
Bruno.cpp: In function 'void Bruno(int, int, std::vector<int>)':
Bruno.cpp:46:8: error: 'a' was not declared in this scope
   46 |     if(a[i] == 2) {
      |        ^
Bruno.cpp:47:11: error: 'st' was not declared in this scope; did you mean 'std'?
   47 |       if(!st[1].empty() && !st[0].empty()) {
      |           ^~
      |           std
Bruno.cpp:57:23: error: 'prev' was not declared in this scope; did you mean 'std::prev'?
   57 |           st[1].erase(prev(st[1].end()));
      |                       ^~~~
      |                       std::prev
In file included from /usr/include/c++/10/bits/stl_algobase.h:66,
                 from /usr/include/c++/10/vector:60,
                 from Bruno.h:1,
                 from Bruno.cpp:1:
/usr/include/c++/10/bits/stl_iterator_base_funcs.h:224:5: note: 'std::prev' declared here
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
Bruno.cpp:64:5: error: 'st' was not declared in this scope; did you mean 'std'?
   64 |     st[a[i]].insert(i);
      |     ^~
      |     std
Bruno.cpp:64:8: error: 'a' was not declared in this scope
   64 |     st[a[i]].insert(i);
      |        ^
Bruno.cpp:68:17: error: 'st' was not declared in this scope; did you mean 'std'?
   68 |     for(auto j: st[i]) {
      |                 ^~
      |                 std