제출 #445606

#제출 시각아이디문제언어결과실행 시간메모리
445606jamezzzRobot (JOI21_ho_t4)C++17
100 / 100
1014 ms54940 KiB
#include <bits/stdc++.h> using namespace std; #define sf scanf #define pf printf #define fi first #define se second #define pb emplace_back #define sz(x) (int)x.size() #define mnto(x,y) x=min(x,(__typeof__(x))y) #define mxto(x,y) x=max(x,(__typeof__(x))y) #define INF 1023456789 #define LINF 1023456789123456789 #define all(x) x.begin(), x.end() typedef long long ll; typedef long double ld; typedef pair<int, int> ii; typedef pair<ll, int> li; typedef tuple<int, int, int> iii; typedef tuple<int, int, int, int> iiii; typedef vector<int> vi; typedef vector<ii> vii; mt19937 rng(time(0)); int n,m,a,b,c,d,cnt; ll tot[500005],dist[500005]; map<ii,int> mp; vector<iii> AL[500005]; priority_queue<li,vector<li>,greater<li>> pq; void add(int a,int b,int c,int d){ if(!mp.count({a,c})){ AL[a].push_back({cnt,0,0}); mp[{a,c}]=cnt++; } int z=mp[{a,c}]; AL[z].push_back({b,c,d}); tot[z]+=d; } void up(int v,ll d){ if(dist[v]<=d)return; dist[v]=d; pq.push({dist[v],v}); } int main(){ sf("%d%d",&n,&m); cnt=n; for(int i=0;i<m;++i){ sf("%d%d%d%d",&a,&b,&c,&d); --a;--b; add(a,b,c,d); add(b,a,c,d); } for(int i=0;i<cnt;++i)dist[i]=LINF; dist[0]=0; pq.push({dist[0],0}); while(!pq.empty()){ ll d;int u;tie(d,u)=pq.top();pq.pop(); if(d>dist[u])continue; if(u<n){ for(iii t:AL[u]){ int v,c,w;tie(v,c,w)=t; for(iii t2:AL[v]){ int v2,c2,w2;tie(v2,c2,w2)=t2; up(v2,d+min((ll)w2,tot[v]-w2)); up(mp[{v2,c2}],d); } } } else{ for(iii t:AL[u]){ int v,c,w;tie(v,c,w)=t; up(v,d+tot[u]-w); } } } if(dist[n-1]==LINF)dist[n-1]=-1; pf("%lld\n",dist[n-1]); }

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

Main.cpp: In function 'int main()':
Main.cpp:48:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |  sf("%d%d",&n,&m);
      |    ^
Main.cpp:51:5: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |   sf("%d%d%d%d",&a,&b,&c,&d);
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...