Submission #635553

#TimeUsernameProblemLanguageResultExecution timeMemory
635553TrentRobot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h"
#include <unordered_map>

using namespace std;
#define ll long long
#define open(g) string _name_ = g; freopen((_name_ + ".in").c_str(), "r", stdin); freopen((_name_ + ".out").c_str(), "w", stdout)
#define printArr(a, len) for(int asdf = 0; asdf < (len); ++asdf) cout << (a)[asdf] << ' '; cout << '\n';
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define forR(i, x) for(int i = 0; i < x; ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(i) i.begin(), i.end()
#define pii pair<int, int>
#define vi vector<int>
#define si set<int>
#define usi unordered_set<int>
#define mii map<int, int>
#define umii unordered_map<int, int>

const int MN = 3e5 + 10;
const ll INF = 1e16;
struct edge{int n, c1, c2, p;};
struct node{int i, cc; ll d;}; // node, color channel (0 for none), distance
bool operator <(const node& a, const node& b){ return a.d > b.d; }
vector<edge> adj[MN];
vector<vector<edge>> ce[MN];
vector<ll> cs[MN], dis[MN];
// gp_hash_table<int, vector<edge>> ce[MN]; // colors split into channels
// gp_hash_table<int, ll> cs[MN]; // color sum of each node
// gp_hash_table<int, ll> dis[MN];
gp_hash_table<int, int> ci[MN];

signed main(){
    boost();
    int N, M; cin >> N >> M;
    REP(i, 1, N + 1) cs[i].push_back(0), dis[i].push_back(INF), ce[i].emplace_back();
    forR(i, M){
        int a, b, c, p; cin >> a >> b >> c >> p;
        if(ci[a].find(c) == ci[a].end()) ci[a][c] = ce[a].size(), cs[a].push_back(0), dis[a].push_back(INF), ce[a].emplace_back();
        if(ci[b].find(c) == ci[b].end()) ci[b][c] = ce[b].size(), cs[b].push_back(0), dis[b].push_back(INF), ce[b].emplace_back();
        adj[a].push_back({b, ci[a][c], ci[b][c], p}); adj[b].push_back({a, ci[b][c], ci[a][c], p});
    }

    REP(i, 1, N + 1){
        dis[i][0] = INF;
        for(auto [n, c1, c2, p] : adj[i]) cs[i][c1] += p, dis[i][c1] = INF, ce[i][c1].push_back({n, c1, c2, p});
    }
    priority_queue<node> dij;
    dij.push({1, 0, 0});
    dis[1][0] = 0;
    while(!dij.empty()){
        auto [i, cc, d] = dij.top(); dij.pop();
        if(cc == 0){
            for(auto [n, c1, c2, p] : adj[i]) {
                ll oc = cs[i][c1] - p;
                if(dis[i][0] + min(oc, (ll) p) < dis[n][0]){
                    dis[n][0] = dis[i][0] + min(oc, (ll) p);
                    dij.push({n, 0, dis[n][0]});
                }
                if(c1 != 0 && dis[i][0] < dis[n][c2]){
                    dis[n][c2] = dis[i][0];
                    dij.push({n, c2, dis[n][c2]});
                }
            }
        } else {
            for(auto [n, c1, c2, p] : ce[i][cc]){
                ll cos = cs[i][cc] - p;
                if(dis[i][cc] + cos < dis[n][0]){
                    dis[n][0] = dis[i][cc] + cos;
                    dij.push({n, 0, dis[n][0]});
                }
            }
        }
    }
    cout << (dis[N][0] >= INF ? -1 : dis[N][0]) << '\n';
}

Compilation message (stderr)

Main.cpp:30:1: error: 'gp_hash_table' does not name a type
   30 | gp_hash_table<int, int> ci[MN];
      | ^~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:38:12: error: 'ci' was not declared in this scope; did you mean 'c'?
   38 |         if(ci[a].find(c) == ci[a].end()) ci[a][c] = ce[a].size(), cs[a].push_back(0), dis[a].push_back(INF), ce[a].emplace_back();
      |            ^~
      |            c
Main.cpp:39:12: error: 'ci' was not declared in this scope; did you mean 'c'?
   39 |         if(ci[b].find(c) == ci[b].end()) ci[b][c] = ce[b].size(), cs[b].push_back(0), dis[b].push_back(INF), ce[b].emplace_back();
      |            ^~
      |            c
Main.cpp:40:30: error: 'ci' was not declared in this scope; did you mean 'c'?
   40 |         adj[a].push_back({b, ci[a][c], ci[b][c], p}); adj[b].push_back({a, ci[b][c], ci[a][c], p});
      |                              ^~
      |                              c
Main.cpp:40:52: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   40 |         adj[a].push_back({b, ci[a][c], ci[b][c], p}); adj[b].push_back({a, ci[b][c], ci[a][c], p});
      |                                                    ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const edge&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:40:98: error: no matching function for call to 'std::vector<edge>::push_back(<brace-enclosed initializer list>)'
   40 |         adj[a].push_back({b, ci[a][c], ci[b][c], p}); adj[b].push_back({a, ci[b][c], ci[a][c], p});
      |                                                                                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const edge&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = edge; _Alloc = std::allocator<edge>; std::vector<_Tp, _Alloc>::value_type = edge]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<edge>::value_type&&' {aka 'edge&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Main.cpp:45:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   45 |         for(auto [n, c1, c2, p] : adj[i]) cs[i][c1] += p, dis[i][c1] = INF, ce[i][c1].push_back({n, c1, c2, p});
      |                  ^
Main.cpp:51:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   51 |         auto [i, cc, d] = dij.top(); dij.pop();
      |              ^
Main.cpp:53:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   53 |             for(auto [n, c1, c2, p] : adj[i]) {
      |                      ^
Main.cpp:65:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   65 |             for(auto [n, c1, c2, p] : ce[i][cc]){
      |                      ^