Submission #224163

#TimeUsernameProblemLanguageResultExecution timeMemory
224163cheehengOlympic Bus (JOI20_ho_t4)C++14
0 / 100
99 ms4448 KiB
#include <bits/stdc++.h> using namespace std; typedef tuple<int, int, int> iii; typedef pair<long long, long long> ii; const long long INF = 1LL << 61; set<iii> AdjList[205]; int cnt[205][205]; int U[50005]; int V[50005]; int C[50005]; int D[50005]; long long dist[205]; int N, M; long long dijkstra(){ for(int i = 1; i <= N; i ++){ dist[i] = INF; } dist[1] = 0; priority_queue<ii, vector<ii>, greater<ii> > pq; while(!pq.empty()){ long long d, u; ii temp = pq.top(); pq.pop(); tie(d, u) = temp; if(d > dist[u]){continue;} for(iii v2: AdjList[u]){ int v, w, x; tie(v, w, x) = v2; if(dist[v] > w + dist[u]){ dist[v] = w + dist[u]; pq.push(ii(dist[v], v)); } } } return dist[N]; } int main(){ scanf("%d%d", &N, &M); memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < M; i ++){ int u, v, c, d; scanf("%d%d%d%d", &u, &v, &c, &d); U[i] = u; V[i] = v; C[i] = c; D[i] = d; AdjList[u].insert(iii(v, c, d)); } long long ans = dijkstra(); for(int i = 0; i < M; i ++){ AdjList[U[i]].erase(iii(V[i], C[i], D[i])); AdjList[V[i]].insert(iii(U[i], C[i], D[i])); ans = min(ans, D[i] + dijkstra()); AdjList[V[i]].erase(iii(U[i], C[i], D[i])); AdjList[U[i]].insert(iii(V[i], C[i], D[i])); } if(ans == INF){ ans = -1; } printf("%lld", ans); return 0; }

Compilation message (stderr)

ho_t4.cpp: In function 'int main()':
ho_t4.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &N, &M);
     ~~~~~^~~~~~~~~~~~~~~~
ho_t4.cpp:53:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d", &u, &v, &c, &d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...