Submission #446229

# Submission time Handle Problem Language Result Execution time Memory
446229 2021-07-21T09:58:31 Z stat0r1c Crocodile's Underground City (IOI11_crocodile) C++11
89 / 100
568 ms 47628 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned ll;
template<typename T> using vt = vector<T>;
using vi = vt<int>;
using vvi = vt<vi>;
using ii = pair<int, int>;
using vii = vt<ii>;
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define debug(x) cerr << #x << " -> " << x << '\n'
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int inf = 1e9 + 7;
const ll infll = 1e18 + 10;
using pll = pair<ll, ll>;
int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
  vt<vii> a(n);
  for(int i = 0; i < m; i++) {
    a[r[i][0]].eb(l[i],r[i][1]);
    a[r[i][1]].eb(l[i],r[i][0]);
  }
  vt<pll> d(n, {infll, infll});
  priority_queue<pll, vt<pll>, greater<pll>> pq;
  for(int i = 0; i < k; i++) {
    d[p[i]] = {0,0};
    pq.push({0, p[i]});  
  }
  while(!pq.empty()) {
    ll du = pq.top().F, u = pq.top().S;
    pq.pop();
    if(du != d[u].S || u == 0) continue;
    for(ii v : a[u]) {
      if(d[v.S].F > du + v.F) {
        d[v.S] = mp(du + v.F, d[v.S].F);
        if(d[v.S].S != infll) pq.push({d[v.S].S, v.S});
      }
      else if(d[v.S].S > du + v.F) pq.push({d[v.S].S = du + v.F, v.S});
    }
  }
  return d[0].S;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 5 ms 712 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 2 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 5 ms 712 KB Output is correct
13 Correct 4 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 466 ms 41236 KB Output is correct
17 Correct 80 ms 11244 KB Output is correct
18 Correct 101 ms 12568 KB Output is correct
19 Correct 568 ms 47628 KB Output is correct
20 Correct 311 ms 34260 KB Output is correct
21 Correct 39 ms 4804 KB Output is correct
22 Incorrect 328 ms 30384 KB Output isn't correct