제출 #475940

#제출 시각아이디문제언어결과실행 시간메모리
475940s_jaskaran_sRobot (JOI21_ho_t4)C++17
0 / 100
37 ms4256 KiB
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n,m; cin>>n>>m; vector<pair<int,pair<int,int>>> v[n+1]; for(int i=0;i<m;i++){ int a,b,c,d; cin>>a>>b>>c>>d; v[a].push_back({b,{c,d}}); } vector<ll> d(n+1,1000000000000000000); d[1]=0; set<pair<ll,ll>> s; s.insert({0,1}); vector<int> b(n+1); while(s.size()){ int p=s.begin()->second; b[p]=1; s.erase(s.begin()); map<int,int> r; for(auto u:v[p]){ r[u.second.first]++; } for(auto u:v[p]){ if(b[u.first]==0){ if(s.count({d[u.first],u.first})){ s.erase({d[u.first],u.first}); } if(r[u.second.first]==1){ d[u.first]=min(d[u.first],d[p]); } else{ d[u.first]=min(d[u.first],d[p]+u.second.second); } s.insert({d[u.first],u.first}); } } } if(d[n]==1000000000000000000){ cout<<-1; return 0; } cout<<d[n]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...