Submission #955379

#TimeUsernameProblemLanguageResultExecution timeMemory
955379blackslexCommuter Pass (JOI18_commuter_pass)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; int n, m, s, t, cs, ct, x, y, z; int main() { scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct); vector<vector<pii>> v(n + 5, vector<pii>()); while (m--) scanf("%lld %lld %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z); vector<ll> d(n + 5, 1e18), par(n + 5); priority_queue<pii, vector<pii>, greater<pii>> pq; pq.emplace(d[s] = 0, s); while (!pq.empty()) { auto [nd, nn] = pq.top(); pq.pop(); for (auto &[tn, td]: v[nn]) if (d[tn] > d[nn] + td) par[tn] = nn, pq.emplace(d[tn] = d[nn] + td, tn); } vector<int> u{t}; while (par[u.back()]) u.emplace_back(par[u.back()]); for (auto &e: u) v[n + 1].emplace_back(e, 0), v[e].emplace_back(n + 1, 0); vector<ll> d2(n + 5, 1e9); pq.emplace(d2[cs] = 0, cs); while (!pq.empty()) { auto [nd, nn] = pq.top(); pq.pop(); for (auto &[tn, td]: v[nn]) if (d2[tn] > d2[nn] + td) pq.emplace(d2[tn] = d2[nn] + td, tn); } printf("%lld", d2[ct]); }

Compilation message (stderr)

commuter_pass.cpp: In function 'int main()':
commuter_pass.cpp:10:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |            ~~~^                            ~~
      |               |                            |
      |               long long int*               int*
      |            %d
commuter_pass.cpp:10:20: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |                 ~~~^                           ~~
      |                    |                           |
      |                    long long int*              int*
      |                 %d
commuter_pass.cpp:10:25: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |                      ~~~^                          ~~
      |                         |                          |
      |                         long long int*             int*
      |                      %d
commuter_pass.cpp:10:30: warning: format '%lld' expects argument of type 'long long int*', but argument 5 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |                           ~~~^                         ~~
      |                              |                         |
      |                              long long int*            int*
      |                           %d
commuter_pass.cpp:10:35: warning: format '%lld' expects argument of type 'long long int*', but argument 6 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |                                ~~~^                        ~~~
      |                                   |                        |
      |                                   long long int*           int*
      |                                %d
commuter_pass.cpp:10:40: warning: format '%lld' expects argument of type 'long long int*', but argument 7 has type 'int*' [-Wformat=]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |                                     ~~~^                        ~~~
      |                                        |                        |
      |                                        long long int*           int*
      |                                     %d
commuter_pass.cpp:12:27: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   12 |     while (m--) scanf("%lld %lld %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z);
      |                        ~~~^             ~~
      |                           |             |
      |                           |             int*
      |                           long long int*
      |                        %d
commuter_pass.cpp:12:32: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
   12 |     while (m--) scanf("%lld %lld %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z);
      |                             ~~~^            ~~
      |                                |            |
      |                                |            int*
      |                                long long int*
      |                             %d
commuter_pass.cpp:12:37: warning: format '%lld' expects argument of type 'long long int*', but argument 4 has type 'int*' [-Wformat=]
   12 |     while (m--) scanf("%lld %lld %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z);
      |                                  ~~~^           ~~
      |                                     |           |
      |                                     |           int*
      |                                     long long int*
      |                                  %d
commuter_pass.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%lld %lld %lld %lld %lld %lld", &n, &m, &s, &t, &cs, &ct);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
commuter_pass.cpp:12:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     while (m--) scanf("%lld %lld %lld", &x, &y, &z), v[x].emplace_back(y, z), v[y].emplace_back(x, z);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...