Submission #836775

#TimeUsernameProblemLanguageResultExecution timeMemory
836775TS_2392Robot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define fileIO(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);} #define SPEED ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0) #define eb emplace_back #define fi first #define se second #define mp make_pair typedef long long ll; typedef pair<int, int> pii; template<class T1, class T2> bool minimize(T1 &a, T2 b){return a > b ? a = b, true : false;} const int N = 1e5 + 3; const ll oo = 1e17; int n, m; struct adjNode{ pii v; int c, p; }; map< int, ll > sump[N], d[N]; map< int, vector<adjNode> > adj[N]; priority_queue< pair<ll, pii>, vector< pair<ll, pii> >, greater< pair<ll, pii> > > pq; void add_edge(pii a, pii b, int c, int p){ adj[a.fi][a.se].pb({b, c, p}); adj[b.fi][b.se].pb({a, c, p}); } int main(){ SPEED; fileIO("text"); cin >> n >> m; for(int i = 1; i <= m; ++i){ int u, v, c, p; cin >> u >> v >> c >> p; add_edge({u, 0}, {v, 0}, c, p); add_edge({u, 0}, {v, c}, c, p); add_edge({u, c}, {v, 0}, c, p); } for(int u = 1; u <= n; ++u){ for(auto &[c, x] : adj[u]){ ll tot = 0; for(auto e : x) tot += e.p; d[u][c] = oo; sump[u][c] = tot; } } d[1][0] = 0; pq.epl(0, mp(1, 0)); while(!pq.empty()){ ll dist = pq.top().fi; int u, x; tie(u, x) = pq.top().se; pq.pop(); if(dist != d[u][x]) continue; for(auto &[b, c, p] : adj[u][x]){ int v, y; tie(v, y) = b; if(x == 0){ if(!y && minimize(d[v][y], d[u][x] + min(1LL * p, sump[u][c] - p))) pq.epl(d[v][y], mp(v, y)); else if(y && minimize(d[v][y], d[u][x])) pq.epl(d[v][y], mp(v, y)); } else if(!y && minimize(d[v][y], d[u][x] + sump[u][x] - p)) pq.epl(d[v][y], mp(v, y)); } } cout << (d[n][0] == oo ? -1 : d[n][0]); return 0; }

Compilation message (stderr)

Main.cpp: In function 'void add_edge(pii, pii, int, int)':
Main.cpp:28:21: error: 'std::map<int, std::vector<adjNode> >::mapped_type' {aka 'class std::vector<adjNode>'} has no member named 'pb'
   28 |     adj[a.fi][a.se].pb({b, c, p});
      |                     ^~
Main.cpp:29:21: error: 'std::map<int, std::vector<adjNode> >::mapped_type' {aka 'class std::vector<adjNode>'} has no member named 'pb'
   29 |     adj[b.fi][b.se].pb({a, c, p});
      |                     ^~
Main.cpp: In function 'int main()':
Main.cpp:42:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   42 |         for(auto &[c, x] : adj[u]){
      |                   ^
Main.cpp:48:21: error: 'class std::priority_queue<std::pair<long long int, std::pair<int, int> >, std::vector<std::pair<long long int, std::pair<int, int> > >, std::greater<std::pair<long long int, std::pair<int, int> > > >' has no member named 'epl'
   48 |     d[1][0] = 0; pq.epl(0, mp(1, 0));
      |                     ^~~
Main.cpp:54:19: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   54 |         for(auto &[b, c, p] : adj[u][x]){
      |                   ^
Main.cpp:57:88: error: 'class std::priority_queue<std::pair<long long int, std::pair<int, int> >, std::vector<std::pair<long long int, std::pair<int, int> > >, std::greater<std::pair<long long int, std::pair<int, int> > > >' has no member named 'epl'
   57 |                 if(!y && minimize(d[v][y], d[u][x] + min(1LL * p, sump[u][c] - p))) pq.epl(d[v][y], mp(v, y));
      |                                                                                        ^~~
Main.cpp:58:61: error: 'class std::priority_queue<std::pair<long long int, std::pair<int, int> >, std::vector<std::pair<long long int, std::pair<int, int> > >, std::greater<std::pair<long long int, std::pair<int, int> > > >' has no member named 'epl'
   58 |                 else if(y && minimize(d[v][y], d[u][x])) pq.epl(d[v][y], mp(v, y));
      |                                                             ^~~
Main.cpp:60:75: error: 'class std::priority_queue<std::pair<long long int, std::pair<int, int> >, std::vector<std::pair<long long int, std::pair<int, int> > >, std::greater<std::pair<long long int, std::pair<int, int> > > >' has no member named 'epl'
   60 |             else if(!y && minimize(d[v][y], d[u][x] + sump[u][x] - p)) pq.epl(d[v][y], mp(v, y));
      |                                                                           ^~~
Main.cpp:5:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileIO(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:12: note: in expansion of macro 'fileIO'
   32 |     SPEED; fileIO("text");
      |            ^~~~~~
Main.cpp:5:90: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 | #define fileIO(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                                                                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:32:12: note: in expansion of macro 'fileIO'
   32 |     SPEED; fileIO("text");
      |            ^~~~~~