제출 #417547

#제출 시각아이디문제언어결과실행 시간메모리
417547APROHACKRobot (JOI21_ho_t4)C++14
0 / 100
63 ms11112 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define PB push_back #define ll long long // Mira las constantes // Estudia las propiedades // Keep calm ll n, m; vector<pair<pair<int, ll>, int> >g[100001]; ll dijkstra(){ priority_queue<pair<ll, int> >pq; pq.push({0, 1}); ll u, v,ci; ll D[100001]; for(int i = 0 ; i <= 100000 ; i++)D[i]=LLONG_MAX; while(pq.size()){ u=pq.top().S; ci=(pq.top().F)*-1; pq.pop(); bool isval=true; for(int i = 0 ; i < g[u].size() ; i++){ if(i>0&&g[u][i-1].F.F==g[u][i].F.F)isval=false; if(i+1<g[u].size()&&g[u][i+1].F.F==g[u][i].F.F)isval=false; if(isval){ if(D[g[u][i].S]>ci){ D[g[u][i].S]=ci; pq.push({-1*(ci), g[u][i].S}); }else{ continue; } }else{ if(D[g[u][i].S]>ci+g[u][i].F.S){ D[g[u][i].S]=ci+g[u][i].F.S; pq.push({-1*(ci+g[u][i].F.S), g[u][i].S}); }else{ continue; } } } } return D[n]; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); cin>>n>>m; ll a, b, c, p; for(int i = 0 ; i < m ; i++){ cin>>a>>b>>c>>p; g[a].PB({{c, p}, b}); g[b].PB({{c, p}, a}); } for(int i = 1 ; i <= n; i++){ sort(g[i].begin(), g[i].end()); } ll res=dijkstra(); if(res==LLONG_MAX){ cout<<"-1\n"; }else{ cout<<res; } }

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

Main.cpp: In function 'long long int dijkstra()':
Main.cpp:23:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, long long int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for(int i = 0 ; i < g[u].size() ; i++){
      |                         ~~^~~~~~~~~~~~~
Main.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, long long int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |             if(i+1<g[u].size()&&g[u][i+1].F.F==g[u][i].F.F)isval=false;
      |                ~~~^~~~~~~~~~~~
Main.cpp:15:11: warning: unused variable 'v' [-Wunused-variable]
   15 |     ll u, v,ci;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...