Submission #745743

#TimeUsernameProblemLanguageResultExecution timeMemory
745743chanhchuong123Commuter Pass (JOI18_commuter_pass)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define task "" #define fi first #define se second #define MASK(i) (1 << (i)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define BIT(mask, i) ((mask) >> (i) & 1) #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i) #define FORD(i, a, b) for (int i = (b), _a = (a); i >= _a; --i) template <typename T1, typename T2> bool minimize(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maximize(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } const int dx[] = {-1, 0, 0, +1}; const int dy[] = {0, -1, +1, 0}; const long long INF = 1e18; const int MAX = 100100; int n, m; int S, T; int U, V; long long dpU[MAX]; long long dpV[MAX]; long long d[4][MAX]; vector<pair<int, int>> adj[MAX]; void dijkstra(int t, int s) { priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq; for (int i = 1; i <= n; ++i) d[t][i] = INF; pq.push({0, s}); d[t][s] = 0; while (pq.size()) { long long dist = pq.top().fi; int u = pq.top().se; pq.pop(); if (dist != d[t][u]) continue; for (pair<int, int> &x: adj[u]) { int v = x.fi, w = x.se; if (minimize(d[t][v], dist + w)) pq.push({d[t][v], v}); } } } void dfsCalc(int u, int p, long long &ans) { minimize(dpU[u], d[2][u]); minimize(dpV[u], d[3][u]); minimize(ans, dpU[u] + d[3][u]); minimize(ans, dpV[u] + d[2][u]); for (pair<int, int> &x: adj[u]) if (x.fi != p) { int v = x.fi, w = x.se; if (d[0][u] + w + d[1][v] == d[0][T]) { minimize(dpU[v], dpU[u]); minimize(dpV[v], dpV[u]); dfsCalc(v, ans); } } } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } cin >> n >> m; cin >> S >> T; cin >> U >> V; for (int i = 1; i <= m; ++i) { int u, v, c; cin >> u >> v >> c; adj[u].push_back({v, c}); adj[v].push_back({u, c}); } dijkstra(0, S); dijkstra(1, T); dijkstra(2, U); dijkstra(3, V); memset(dpU, 0x3f, sizeof dpU); memset(dpV, 0x3f, sizeof dpV); long long ans = d[2][V]; dfsCalc(S, ans); cout << ans; return 0; }

Compilation message (stderr)

commuter_pass.cpp: In function 'void dfsCalc(int, int, long long int&)':
commuter_pass.cpp:61:27: error: too few arguments to function 'void dfsCalc(int, int, long long int&)'
   61 |             dfsCalc(v, ans);
      |                           ^
commuter_pass.cpp:51:6: note: declared here
   51 | void dfsCalc(int u, int p, long long &ans) {
      |      ^~~~~~~
commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:88:19: error: too few arguments to function 'void dfsCalc(int, int, long long int&)'
   88 |     dfsCalc(S, ans);
      |                   ^
commuter_pass.cpp:51:6: note: declared here
   51 | void dfsCalc(int u, int p, long long &ans) {
      |      ^~~~~~~
commuter_pass.cpp:71:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:72:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~