Submission #1159167

#TimeUsernameProblemLanguageResultExecution timeMemory
1159167shnThe Potion of Great Power (CEOI20_potion)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back #define len(s) (int)(s.size()) #define F first #define S second const int N = 2e5; int n , d , h[N]; int u , a[N], b[N]; pll last[N]; vector < int > g[N]; vector < pll > f[N]; map < pll , int > mp; void init(int N, int D, int H[]) { n = N; d = D; for(int i = 0; i < n; i++) h[i] = H[i]; } void curseChanges(int U, int A[], int B[]) { u = U; for(int i = 0; i < u; i++){ a[i] = A[i]; b[i] = B[i]; if(!last[a[i]]) g[i][0].pb(b[i]); else{ for(int it : g[last[a[i]].F][last[a[i]].S]) g[i][0].pb(it); if(!mp[{a[i] , b[i]}]) g[i][0].pb(b[i]); else{ vector < int > zam; for(int it : g[i][0]){ if(it != b[i]) zam.pb(it); } g[i][0].clear(); for(int it : zam) g[i][0].pb(it); } } if(!last[b[i]]) g[i][1].pb(a[i]); else{ for(int it : g[last[b[i]].F][last[b[i]].S]) g[i][1].pb(it); if(!mp[{a[i] , b[i]}]) g[i][1].pb(a[i]); else{ vector < int > zam; for(int it : g[i][1]){ if(it != a[i]) zam.pb(it); } g[i][1].clear(); for(int it : zam) g[i][1].pb(it); } } last[a[i]] = {i , 0}; last[b[i]] = {i , 1}; mp[{a[i] , b[i]}] ^= 1; mp[{b[i] , a[i]}] ^= 1; f[a[i]].pb(i); f[b[i]].pb(i); } } int find(int x , int w){ int l = 0 , r = len(f[x]) - 1 , res = u; while(l <= r){ int mid = (l + r) >> 1; if(f[x][mid].first <= w){ l = mid + 1; res = mid; } else{ r = mid - 1; } } return res; } int question(int x, int y, int v) { int lstx = find(x , v) , lsty = find(y , v); if(lstx == u || lsty == u) return 1000000000; int mn = 1000000000; int c = 0 , d = 0; if(g[f[x][lstx]][0] != x) c++; if(g[f[y][lsty]][0] != y) d++; for(int it : g[f[x][lstx]][c]){ for(int it2 : g[f[y][lsty]][d]){ mn = min(mn , abs(h[it] - h[it2])); } } return mn; }

Compilation message (stderr)

potion.cpp:12:1: error: 'pll' does not name a type
   12 | pll last[N];
      | ^~~
potion.cpp:14:1: error: 'vector' does not name a type
   14 | vector < int > g[N];
      | ^~~~~~
potion.cpp:16:10: error: 'pll' was not declared in this scope
   16 | vector < pll > f[N];
      |          ^~~
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:10: error: 'pll' was not declared in this scope
potion.cpp:16:1: error: 'vector' does not name a type
   16 | vector < pll > f[N];
      | ^~~~~~
potion.cpp:18:7: error: 'pll' was not declared in this scope
   18 | map < pll , int > mp;
      |       ^~~
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:7: error: 'pll' was not declared in this scope
potion.cpp:18:1: error: 'map' does not name a type
   18 | map < pll , int > mp;
      | ^~~
potion.cpp: In function 'void curseChanges(int, int*, int*)':
potion.cpp:31:21: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   31 |                 if(!last[a[i]]) g[i][0].pb(b[i]);
      |                     ^~~~
      |                     std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from potion.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~
potion.cpp:31:33: error: 'g' was not declared in this scope
   31 |                 if(!last[a[i]]) g[i][0].pb(b[i]);
      |                                 ^
potion.cpp:33:38: error: 'g' was not declared in this scope
   33 |                         for(int it : g[last[a[i]].F][last[a[i]].S]) g[i][0].pb(it);
      |                                      ^
potion.cpp:34:29: error: 'mp' was not declared in this scope
   34 |                         if(!mp[{a[i] , b[i]}]) g[i][0].pb(b[i]);
      |                             ^~
potion.cpp:34:48: error: 'g' was not declared in this scope
   34 |                         if(!mp[{a[i] , b[i]}]) g[i][0].pb(b[i]);
      |                                                ^
potion.cpp:36:33: error: 'vector' was not declared in this scope
   36 |                                 vector < int > zam;
      |                                 ^~~~~~
potion.cpp:36:33: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
potion.cpp:36:42: error: expected primary-expression before 'int'
   36 |                                 vector < int > zam;
      |                                          ^~~
potion.cpp:37:46: error: 'g' was not declared in this scope
   37 |                                 for(int it : g[i][0]){
      |                                              ^
potion.cpp:38:56: error: 'zam' was not declared in this scope
   38 |                                         if(it != b[i]) zam.pb(it);
      |                                                        ^~~
potion.cpp:40:33: error: 'g' was not declared in this scope
   40 |                                 g[i][0].clear();
      |                                 ^
potion.cpp:41:46: error: 'zam' was not declared in this scope
   41 |                                 for(int it : zam) g[i][0].pb(it);
      |                                              ^~~
potion.cpp:44:21: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   44 |                 if(!last[b[i]]) g[i][1].pb(a[i]);
      |                     ^~~~
      |                     std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from potion.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~
potion.cpp:44:33: error: 'g' was not declared in this scope
   44 |                 if(!last[b[i]]) g[i][1].pb(a[i]);
      |                                 ^
potion.cpp:46:38: error: 'g' was not declared in this scope
   46 |                         for(int it : g[last[b[i]].F][last[b[i]].S]) g[i][1].pb(it);
      |                                      ^
potion.cpp:47:29: error: 'mp' was not declared in this scope
   47 |                         if(!mp[{a[i] , b[i]}]) g[i][1].pb(a[i]);
      |                             ^~
potion.cpp:47:48: error: 'g' was not declared in this scope
   47 |                         if(!mp[{a[i] , b[i]}]) g[i][1].pb(a[i]);
      |                                                ^
potion.cpp:49:33: error: 'vector' was not declared in this scope
   49 |                                 vector < int > zam;
      |                                 ^~~~~~
potion.cpp:49:33: note: suggested alternatives:
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
potion.cpp:49:42: error: expected primary-expression before 'int'
   49 |                                 vector < int > zam;
      |                                          ^~~
potion.cpp:50:46: error: 'g' was not declared in this scope
   50 |                                 for(int it : g[i][1]){
      |                                              ^
potion.cpp:51:56: error: 'zam' was not declared in this scope
   51 |                                         if(it != a[i]) zam.pb(it);
      |                                                        ^~~
potion.cpp:53:33: error: 'g' was not declared in this scope
   53 |                                 g[i][1].clear();
      |                                 ^
potion.cpp:54:46: error: 'zam' was not declared in this scope
   54 |                                 for(int it : zam) g[i][1].pb(it);
      |                                              ^~~
potion.cpp:57:17: error: 'last' was not declared in this scope; did you mean 'std::chrono::last'?
   57 |                 last[a[i]] = {i , 0};
      |                 ^~~~
      |                 std::chrono::last
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:101,
                 from potion.cpp:1:
/usr/include/c++/11/chrono:1276:32: note: 'std::chrono::last' declared here
 1276 |     inline constexpr last_spec last{};
      |                                ^~~~
potion.cpp:59:17: error: 'mp' was not declared in this scope
   59 |                 mp[{a[i] , b[i]}] ^= 1;
      |                 ^~
potion.cpp:61:17: error: 'f' was not declared in this scope
   61 |                 f[a[i]].pb(i);
      |                 ^
potion.cpp: In function 'int find(int, int)':
potion.cpp:67:29: error: 'f' was not declared in this scope
   67 |         int l = 0 , r = len(f[x]) - 1 , res = u;
      |                             ^
potion.cpp:3:22: note: in definition of macro 'len'
    3 | #define len(s) (int)(s.size())
      |                      ^
potion.cpp:72:25: error: 'res' was not declared in this scope
   72 |                         res = mid;
      |                         ^~~
potion.cpp:78:16: error: 'res' was not declared in this scope
   78 |         return res;
      |                ^~~
potion.cpp: In function 'int question(int, int, int)':
potion.cpp:86:12: error: 'g' was not declared in this scope
   86 |         if(g[f[x][lstx]][0] != x) c++;
      |            ^
potion.cpp:86:14: error: 'f' was not declared in this scope
   86 |         if(g[f[x][lstx]][0] != x) c++;
      |              ^
potion.cpp:87:12: error: 'g' was not declared in this scope
   87 |         if(g[f[y][lsty]][0] != y) d++;
      |            ^
potion.cpp:87:14: error: 'f' was not declared in this scope
   87 |         if(g[f[y][lsty]][0] != y) d++;
      |              ^
potion.cpp:88:22: error: 'g' was not declared in this scope
   88 |         for(int it : g[f[x][lstx]][c]){
      |                      ^
potion.cpp:88:24: error: 'f' was not declared in this scope
   88 |         for(int it : g[f[x][lstx]][c]){
      |                        ^
potion.cpp:90:30: error: 'min' was not declared in this scope
   90 |                         mn = min(mn , abs(h[it] - h[it2]));
      |                              ^~~
potion.cpp:90:30: note: suggested alternatives:
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from potion.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   'std::min'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/11/algorithm:64,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from potion.cpp:1:
/usr/include/c++/11/bits/ranges_algo.h:2957:29: note:   'std::ranges::min'
 2957 |   inline constexpr __min_fn min{};
      |                             ^~~