Submission #683561

#TimeUsernameProblemLanguageResultExecution timeMemory
683561yogesh_saneCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
102 ms262144 KiB
#include <iostream> #include <vector> #include <queue> #include <stack> #include <climits> using namespace std; long long const INF = 1e15; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); freopen("in.txt","r",stdin); int n, m, s, t, u, v; cin >> n >> m >> s >> t >> u >> v; vector<vector<long long>>dist(n+1, vector<long long>(n+1, INF)); for(int i = 0; i < m; i++){ int a, b, c; cin >> a >> b >> c; dist[a][b] = c; dist[b][a] = c; } for(int k = 1; k <= n; k++){ for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]); } } } long long ans = dist[u][v]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(dist[s][i]+dist[i][j]+dist[j][t] == dist[s][t]){ ans = min(ans, min(dist[i][u]+dist[j][v],dist[i][v]+dist[j][u])); } } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

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