Submission #502544

#TimeUsernameProblemLanguageResultExecution timeMemory
502544fabijan_cikacXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" void solve(int N){ int m[10010][10010]; vector<pair<int, int> > v; int a[15000]; bool b = true; int sol[15000]; m[0][1] = query(0, 1); for (int i = 2; i < N; ++i){ m[i - 2][i] = query(i - 2, i); m[i - 1][i] = query(i - 1, i); } //a[0] < a[1] a[0] = 0; a[1] = m[0][1]; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } if (!b || x > y){ a[0] = 0; a[1] = -m[0][1]; b = true; for (int i = 2; i < N; ++i){ bool c = false; for (int j = -1; j <= 1; ++j){ if (j == 0) continue; a[i] = a[i - 1] + j * m[i - 1][i]; if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){ c = true; break; } } if (!c) b = false; } v.clear(); for (int i = 0; i < N; ++i) v.push_back({a[i], i}); sort(v.begin(), v.end()); int x, y; for (int i = 0; i < n; ++i){ sol[v[i].second] = i + 1; if (i + 1 == 1) x = v[i].second; if (i + 1 == N) y = v[i].second; } } for (int i = 0; i < n; ++i) answer(i + 1, sol[i]); return; }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:5:26: error: 'vector' was not declared in this scope
    5 |     int m[10010][10010]; vector<pair<int, int> > v;
      |                          ^~~~~~
xylophone.cpp:5:26: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.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 /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
xylophone.cpp:5:33: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 |     int m[10010][10010]; vector<pair<int, int> > v;
      |                                 ^~~~
      |                                 std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
xylophone.cpp:5:38: error: expected primary-expression before 'int'
    5 |     int m[10010][10010]; vector<pair<int, int> > v;
      |                                      ^~~
xylophone.cpp:19:31: error: 'max' was not declared in this scope; did you mean 'std::max'?
   19 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                               ^~~
      |                               std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:19:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
   19 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                 ^~~
      |                 std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:19:68: error: 'min' was not declared in this scope; did you mean 'std::min'?
   19 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                                    ^~~
      |                                                                    std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:19:54: error: 'min' was not declared in this scope; did you mean 'std::min'?
   19 |             if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                      ^~~
      |                                                      std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:26:9: error: 'v' was not declared in this scope
   26 |         v.push_back({a[i], i});
      |         ^
xylophone.cpp:27:10: error: 'v' was not declared in this scope
   27 |     sort(v.begin(), v.end()); int x, y;
      |          ^
xylophone.cpp:27:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   27 |     sort(v.begin(), v.end()); int x, y;
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
xylophone.cpp:28:25: error: 'n' was not declared in this scope
   28 |     for (int i = 0; i < n; ++i){
      |                         ^
xylophone.cpp:40:35: error: 'max' was not declared in this scope; did you mean 'std::max'?
   40 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                   ^~~
      |                                   std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:40:21: error: 'max' was not declared in this scope; did you mean 'std::max'?
   40 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                     ^~~
      |                     std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:40:72: error: 'min' was not declared in this scope; did you mean 'std::min'?
   40 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                                        ^~~
      |                                                                        std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:40:58: error: 'min' was not declared in this scope; did you mean 'std::min'?
   40 |                 if (max(a[i - 2], max(a[i - 1], a[i])) - min(a[i - 2], min(a[i - 1], a[i])) == m[i - 2][i]){
      |                                                          ^~~
      |                                                          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
xylophone.cpp:50:29: error: 'n' was not declared in this scope
   50 |         for (int i = 0; i < n; ++i){
      |                             ^
xylophone.cpp:56:25: error: 'n' was not declared in this scope
   56 |     for (int i = 0; i < n; ++i)
      |                         ^