Submission #996025

#TimeUsernameProblemLanguageResultExecution timeMemory
996025anHiepXylophone (JOI18_xylophone)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "xylophone.h" // static int a[5000]; int ans[5004]; void solve(int n) { // int value = query(1, N); // for(int i = 1; i <= N; i++) { // answer(i, i); // } int dis = query(1,2); map<pair<int,int>,int> mp; for(int i = 3; i <= n; i++){ mp[{i-1, i}] = query(i-1, i); mp[{i-2, i}] = query(i-2, i); } for(int i = 1; i <= n; i++){ a[1] = i; bool c = 1; if(i + dis <= n){ c = 1; a[2] = i + dis; map<int,int> used; used[a[1]] = 1; used[a[2]] = 1; for(int j = 3; j <= n; j++){ int x = c - mp[{j-1,j}]; if(x >= 1 && used[x] == 0){ if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){ a[j] = x; used[x] = 1; continue; } } x = c + mp[{j-1,j}]; if(x <= n && used[x] == 0){ if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){ a[j] = x; used[x] = 1; continue; } } c = 0; } if(c){ for(int j = 1;j<=n;j++){ answer(j,ans[j]); } return; } } if(i - dis >= 1){ c = 1; a[2] = i - dis; map<int,int> used; used[a[1]] = 1; used[a[2]] = 1; for(int j = 3;j<=n;j++){ int x = c - mp[{j-1, j}]; if(x >= 1 && used[x] == 0){ if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){ a[j] = x; used[x] = 1; continue; } } x = c + mp[{j-1,j}]; if(x <= n && used[x] == 0){ if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){ a[j] = x; used[x] = 1; continue; } } c = 0; } if(c){ for(int j = 1;j<=n;j++){ answer(j,ans[j]); } return; } } } }

Compilation message (stderr)

xylophone.cpp: In function 'void solve(int)':
xylophone.cpp:18:2: error: 'map' was not declared in this scope
   18 |  map<pair<int,int>,int> mp;
      |  ^~~
xylophone.cpp:18:2: note: suggested alternatives:
In file included from /usr/include/c++/10/map:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from xylophone.cpp:1:
/usr/include/c++/10/bits/stl_map.h:100:11: note:   'std::map'
  100 |     class map
      |           ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from xylophone.cpp:1:
/usr/include/c++/10/map:78:13: note:   'std::pmr::map'
   78 |       using map
      |             ^~~
xylophone.cpp:18:6: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
   18 |  map<pair<int,int>,int> mp;
      |      ^~~~
      |      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:18:11: error: expected primary-expression before 'int'
   18 |  map<pair<int,int>,int> mp;
      |           ^~~
xylophone.cpp:20:3: error: 'mp' was not declared in this scope
   20 |   mp[{i-1, i}] = query(i-1, i);
      |   ^~
xylophone.cpp:24:3: error: 'a' was not declared in this scope
   24 |   a[1] = i;
      |   ^
xylophone.cpp:29:8: error: expected primary-expression before 'int'
   29 |    map<int,int> used;
      |        ^~~
xylophone.cpp:30:4: error: 'used' was not declared in this scope
   30 |    used[a[1]] = 1;
      |    ^~~~
xylophone.cpp:34:17: error: 'mp' was not declared in this scope
   34 |     int x = c - mp[{j-1,j}];
      |                 ^~
xylophone.cpp:36:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   36 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |          ^~~
      |          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:36:33: error: 'min' was not declared in this scope; did you mean 'std::min'?
   36 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |                                 ^~~
      |                                 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:44:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   44 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |          ^~~
      |          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:44:33: error: 'min' was not declared in this scope; did you mean 'std::min'?
   44 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |                                 ^~~
      |                                 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:62:8: error: expected primary-expression before 'int'
   62 |    map<int,int> used;
      |        ^~~
xylophone.cpp:63:4: error: 'used' was not declared in this scope
   63 |    used[a[1]] = 1;
      |    ^~~~
xylophone.cpp:66:17: error: 'mp' was not declared in this scope
   66 |     int x = c - mp[{j-1, j}];
      |                 ^~
xylophone.cpp:68:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   68 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |          ^~~
      |          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:68:33: error: 'min' was not declared in this scope; did you mean 'std::min'?
   68 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |                                 ^~~
      |                                 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:76:10: error: 'max' was not declared in this scope; did you mean 'std::max'?
   76 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |          ^~~
      |          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:76:33: error: 'min' was not declared in this scope; did you mean 'std::min'?
   76 |      if((max({x,a[j-1],a[j-2]})-min({x,a[j-1],a[j-2]})==mp[{j-2, j}]) && (max(x,a[j-1]) - min(x,a[j-1])==mp[{j-1,j}])){
      |                                 ^~~
      |                                 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)
      |     ^~~