Submission #750885

#TimeUsernameProblemLanguageResultExecution timeMemory
750885blgutei000Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h" #include<bits/stdc++.h> #include <vector> #define ll long long #define pi pair<ll , ll> #define pb push_back #define mp make_pair #define ff first #define ss second #define sz size() const ll N = 1e18; const int maxn = 1e5 + 1; vector<pair<ll , ll> > adj[maxn]; vector<int> cost; int dist[maxn]; bool vis[maxn] , vis1[maxn]; set<pi> s; set<pi> :: iterator it; void dfs(int a) { vis[a] = true; for(int i = 0; i < adj[a].sz i++) { int b = adj[a][i].ff; if(arr[b] == 0) cost.pb(b); if(!vis[b]) dfs(b); } } double solve(int n, int m, int k, int h, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) { for(int i = 0; i < m; i++) { adj[x[i]].pb(mp(y[i] , c[i])); adj[y[i]].pb(mp(x[i] , c[i])); } for(int i = 0; i < n; i++) { dist[i] = N; } dfs(0); dist[n - 1] = 0; s.insert(0 , n - 1); while(!s.empty()) { it = s.begin(); int u = it -> ss; s.erase(it); if(vis1[u]) continue; vis1[u] = true; for(int i = 0; i < adj[u].sz; i++) { int v = adj[u][i].ff; int w = adj[u][i].ss; if(dist[u] + w < dist[v]) { dist[v] = dist[u] + w; s.insert(mp(dist[v] , v)); } } } ll ans = 0; for(int i = 0; i < cost.sz i++) { if(ans < dist[cost[i]]) ans = dist[cost[i]]; } cout << ans << endl; return -1; }

Compilation message (stderr)

cyberland.cpp:16:1: error: 'vector' does not name a type
   16 | vector<pair<ll , ll> > adj[maxn];
      | ^~~~~~
cyberland.cpp:17:1: error: 'vector' does not name a type
   17 | vector<int> cost;
      | ^~~~~~
cyberland.cpp:20:1: error: 'set' does not name a type; did you mean 'setns'?
   20 | set<pi> s;
      | ^~~
      | setns
cyberland.cpp:21:1: error: 'set' does not name a type; did you mean 'setns'?
   21 | set<pi> :: iterator it;
      | ^~~
      | setns
cyberland.cpp: In function 'void dfs(int)':
cyberland.cpp:24:21: error: 'adj' was not declared in this scope
   24 |  for(int i = 0; i < adj[a].sz i++) {
      |                     ^~~
cyberland.cpp:24:31: error: expected ';' before 'i'
   24 |  for(int i = 0; i < adj[a].sz i++) {
      |                               ^
cyberland.cpp:26:6: error: 'arr' was not declared in this scope
   26 |   if(arr[b] == 0) cost.pb(b);
      |      ^~~
cyberland.cpp:26:19: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   26 |   if(arr[b] == 0) cost.pb(b);
      |                   ^~~~
      |                   cosl
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:32:3: error: 'adj' was not declared in this scope
   32 |   adj[x[i]].pb(mp(y[i] , c[i]));
      |   ^~~
cyberland.cpp:8:12: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
    8 | #define mp make_pair
      |            ^~~~~~~~~
cyberland.cpp:32:16: note: in expansion of macro 'mp'
   32 |   adj[x[i]].pb(mp(y[i] , c[i]));
      |                ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
cyberland.cpp:36:13: warning: overflow in conversion from 'long long int' to 'int' changes value from '1000000000000000000' to '-1486618624' [-Woverflow]
   36 |   dist[i] = N;
      |             ^
cyberland.cpp:40:2: error: 's' was not declared in this scope
   40 |  s.insert(0 , n - 1);
      |  ^
cyberland.cpp:42:3: error: 'it' was not declared in this scope; did you mean 'int'?
   42 |   it = s.begin();
      |   ^~
      |   int
cyberland.cpp:47:22: error: 'adj' was not declared in this scope
   47 |   for(int i = 0; i < adj[u].sz; i++) {
      |                      ^~~
cyberland.cpp:8:12: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'?
    8 | #define mp make_pair
      |            ^~~~~~~~~
cyberland.cpp:52:14: note: in expansion of macro 'mp'
   52 |     s.insert(mp(dist[v] , v));
      |              ^~
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from cyberland.h:1,
                 from cyberland.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:567:5: note: 'std::make_pair' declared here
  567 |     make_pair(_T1&& __x, _T2&& __y)
      |     ^~~~~~~~~
cyberland.cpp:57:21: error: 'cost' was not declared in this scope; did you mean 'cosl'?
   57 |  for(int i = 0; i < cost.sz i++) {
      |                     ^~~~
      |                     cosl
cyberland.cpp:57:29: error: expected ';' before 'i'
   57 |  for(int i = 0; i < cost.sz i++) {
      |                             ^
cyberland.cpp:60:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   60 |  cout << ans << endl;
      |  ^~~~
      |  std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from cyberland.cpp:2:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
cyberland.cpp:60:17: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   60 |  cout << ans << endl;
      |                 ^~~~
      |                 std::endl
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from cyberland.cpp:2:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~