Submission #1248380

#TimeUsernameProblemLanguageResultExecution timeMemory
1248380dungntCommuter Pass (JOI18_commuter_pass)C++20
24 / 100
26 ms2368 KiB
#include<bits/stdc++.h> #define M 100004 #define fi first #define se second #define pii pair<int, int> using namespace std; const long long inf = 1e16; int n, m; int s, t, s1, t1; vector<pii> adj[500]; long long d[500][500]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "baitap" if(fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } cin >> n >> m; cin >> s >> t >> s1 >> t1; for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) if(i != j) d[i][j] = inf; } for(int i = 1; i <= m; i++) { int u, v, w; cin >> u >> v >> w; d[u][v] = min(d[u][v], 1ll * w); d[v][u] = min(d[v][u], 1ll * w); } for(int k = 1; k <= n; k++) { for(int i = 1; i <= n; i++) { for(int j = 1; j <= n; j++) { if(d[i][j] > d[i][k] + d[k][j]) d[i][j] = d[i][k] + d[k][j]; } } } long long ans = d[s1][t1]; for(int x = 1; x <= n; x++) { for(int y = 1; y <= n; y++) { if(d[s][x] + d[x][y] + d[y][t] == d[s][t]) ans = min({ans, d[s1][x] + d[y][t1], d[s1][y] + d[x][t1]}); } } cout << ans; }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...