제출 #450485

#제출 시각아이디문제언어결과실행 시간메모리
450485SirCovidThe19thRobot (JOI21_ho_t4)C++14
0 / 100
1379 ms81532 KiB
#include <bits/stdc++.h>
using namespace std; 

#define ll long long

const int mx = 1e5+5;

int n, m; map<int, vector<tuple<int, int>>> adj[mx]; 
map<int, ll> tot[mx], dst[mx];
priority_queue<tuple<ll, int, int>> pq;

void add(int b, int c, int val){
    if (val < dst[b][c]) dst[b][c] = val, pq.push({-val, b, c});
}
int main(){
    cin >> n >> m;
    for (int i = 0; i < m; i++){
        int a, b, c, w; cin >> a >> b >> c >> w;
        adj[a][c].push_back({b, w});
        adj[b][c].push_back({a, w});
        tot[a][c] += w; tot[b][c] += w;
        dst[a][c] = dst[b][c] = dst[a][0] = dst[b][0] = LLONG_MAX;
    }dst[1][0] = 0; pq.push({0, 1, 0});
    while (!pq.empty()){
        ll cst; int A, C; tie(cst, A, C) = pq.top(); cst *= -1; pq.pop();
        if (cst != dst[A][C]) continue;
        if (C){
            for (auto [b, w] : adj[A][C])
                add(b, 0, tot[A][C] - w + cst);
        }else{
            for (auto c : adj[A]) for (auto [b, w] : c.second){ 
                add(b, 0, tot[A][c.first] - w + cst);
                add(b, 0, w + cst);
                add(b, c.first, cst);
            }
        }
    }cout<<(dst[n][0] == LLONG_MAX ? -1 : dst[n][0])<<endl;
}
 

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:28:23: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |             for (auto [b, w] : adj[A][C])
      |                       ^
Main.cpp:31:45: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   31 |             for (auto c : adj[A]) for (auto [b, w] : c.second){
      |                                             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...