Submission #54265

#TimeUsernameProblemLanguageResultExecution timeMemory
54265CrownCommuter Pass (JOI18_commuter_pass)C++14
0 / 100
46 ms2400 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second #define pb push_back typedef pair<int, int> ii; typedef long long ll; const int maxn = 305; ll dist[maxn][maxn]; int s, t, u, v; int main() { int n, m; scanf("%d %d", &n, &m); scanf("%d %d %d %d", &s, &t, &u, &v); for(int i = 1; i<= n; i++) for(int j = 1; j<= n; j++) dist[i][j] = 1e18; while(m--) { int u, v; scanf("%d %d", &u, &v); int w; scanf("%d", &w); dist[u][v] = dist[v][u] = w; } 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]); ll best = dist[u][v]; for(int u1 = 1; u1<= n; u1++) for(int u2 = 1; u2<= n; u2++) { if(dist[s][u1]+dist[u1][u2]+dist[u2][t] == dist[s][t]) { best = min(best, dist[u][u1]+dist[u2][v]); } } printf("%lld\n", best); }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:17:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, m; scanf("%d %d", &n, &m);
            ~~~~~^~~~~~~~~~~~~~~~~
commuter_pass.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d", &s, &t, &u, &v);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:24:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int u, v; scanf("%d %d", &u, &v);
             ~~~~~^~~~~~~~~~~~~~~~~
commuter_pass.cpp:25:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int w; scanf("%d", &w);
          ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...