Submission #634671

#TimeUsernameProblemLanguageResultExecution timeMemory
634671uroskRobot (JOI21_ho_t4)C++14
Compilation error
0 ms0 KiB
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll long long
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
using namespace __gnu_pbds;
/*
ll add(ll x,ll y){
    x+=y;
    if(x<0){
        x%=mod;
        x+=mod;
    }else{
        if(x>=mod) x%=mod;
    }
    return x;
}
ll mul(ll a,ll b){
	ll ans = (a*b)%mod;
	if(ans<0) ans+=mod;
	return ans;
}
typedef tree<int,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<int,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll l,ll r){
    return uniform_int_distribution<ll>(l,r)(rng);
}
*/
#define maxn 100005
ll n,m;
vector<array<ll,3> > g[maxn];
map<ll,ll> sum[maxn];
map<ll,ll> mx[maxn];
ll d[maxn];
bool vis[maxn],vis2[maxn];
map<ll,ll> d2[maxn];
struct nxt{
    ll fi,p,c,d;
};
bool cmp(nxt a,nxt b){
    if(a.d!=b.d) return a.d>b.d;
    return a.p>b.p;
}
priority_queue<nxt,vector<nxt>,decltype(&cmp)> pq(cmp);
int main(){
	daj_mi_malo_vremena
    cin >> n >> m;
    for(ll i = 1;i<=m;i++){
        ll x,y,c,p;
        cin >> x >> y >> c >> p;
        sum[x][c]+=p; sum[y][c]+=p;
        mx[x][c] = max(mx[x][c],p);
        mx[y][c] = max(mx[y][c],p);
        g[x].pb({y,c,p});
        g[y].pb({x,c,p});
    }
    fill(d,d+maxn,llinf);
    d[1] = 0;
    pq.push({1,0,0,0});
    while(sz(pq)){
        nxt g = pq.top(); pq.pop();
        ll u = g.fi;
        bool f = !!g.c;
        if(!f&&vis[u]) continue;
        else vis[u] = 1;
        if(f&&vis2[u]) continue;
        else vis2[u] = 1;
        if(f){
            for(array<ll,3> a : g[u]){
                ll s = a[0]; ll c = a[1]; ll p = a[2];
                if(c!=g.c) continue;
                ll w = sum[u][c]-p;
                if(g.d+w<d[s]){
                    pq.push({s,p,c,d[u]+w});
                }
            }
            continue;
        }
        for(array<ll,3> a : g[u]){
            ll s = a[0]; ll c = a[1]; ll p = a[2];
            ll w = min(p,sum[u][c]-p);
            if(g.d+w<d[s]){
                d[s] = g.d + w;
                pq.push({s,0,0,d[u]+w});
            }
            if(d2[s].count(c)==0||g.d<d2[s][c]){
                d2[s][c] = g.d;
                pq.push({s,p,c,g.d});
            }
        }
    }
    ll ans = d[n];
    if(ans==llinf) ans = -1;
    cout<<ans<<endl;
	return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:86:34: error: no match for 'operator[]' (operand types are 'nxt' and 'long long int')
   86 |             for(array<ll,3> a : g[u]){
      |                                  ^
Main.cpp:96:30: error: no match for 'operator[]' (operand types are 'nxt' and 'long long int')
   96 |         for(array<ll,3> a : g[u]){
      |                              ^