Submission #1104390

# Submission time Handle Problem Language Result Execution time Memory
1104390 2024-10-23T14:54:11 Z M_W_13 Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
537 ms 90284 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)

const ll INF = 1e18;
const int MAXN = 1e5 + 7;
vector<pair<int, ll>> graf[MAXN];
ll dl[MAXN][2];

class compare {
  public:
    bool operator() (pair<ll, int> a, pair<ll, int> b) {
      return a.first > b.first;
    }
};

int travel_plan(int n, int m, int R[][2], int L[], int K, int P[])
{
  rep(i, MAXN) {
    rep(j, 2){ 
      dl[i][j] = INF;
    }
  }
  rep(i, m) {
    int a = R[i][0];
    int b = R[i][1];
    ll waga = L[i];
    graf[a].push_back({b, waga});
    graf[b].push_back({a, waga});
  }
  bool odwiedzone[n];
  rep(i, n) {
    odwiedzone[i] = false;
  }

  //dijkstra:
  priority_queue<pair<ll, int>, vector<pair<ll, int>>, compare> pq;
  rep(i, K) {
    dl[P[i]][0] = 0;
    dl[P[i]][1] = 0;
    pq.push({0, P[i]});
  }
  while (!pq.empty()) {
    pair<ll, int> p = pq.top();
    pq.pop();
    if (odwiedzone[p.second]) {
      continue;
    }
    // cout << "v = " << p.second << " ile = " << p.first << '\n';
    if (dl[p.second][0] < INF) {
      odwiedzone[p.second] = true;
      dl[p.second][1] = p.first;
      for (auto syn: graf[p.second]) {
        if (!odwiedzone[syn.first]) {
          pq.push({syn.second + p.first, syn.first});
        }
      }
    }
    else {
      dl[p.second][0] = p.first;
    }
  }
  return dl[0][1];
}


# Verdict Execution time Memory Grader output
1 Correct 2 ms 6736 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 2 ms 6736 KB Output is correct
4 Correct 2 ms 6848 KB Output is correct
5 Correct 2 ms 6736 KB Output is correct
6 Correct 2 ms 6736 KB Output is correct
7 Correct 2 ms 6736 KB Output is correct
8 Correct 2 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6736 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 2 ms 6736 KB Output is correct
4 Correct 2 ms 6848 KB Output is correct
5 Correct 2 ms 6736 KB Output is correct
6 Correct 2 ms 6736 KB Output is correct
7 Correct 2 ms 6736 KB Output is correct
8 Correct 2 ms 6736 KB Output is correct
9 Correct 3 ms 9296 KB Output is correct
10 Correct 2 ms 6736 KB Output is correct
11 Correct 2 ms 6736 KB Output is correct
12 Correct 5 ms 9808 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 2 ms 6736 KB Output is correct
15 Correct 2 ms 6736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6736 KB Output is correct
2 Correct 1 ms 6604 KB Output is correct
3 Correct 2 ms 6736 KB Output is correct
4 Correct 2 ms 6848 KB Output is correct
5 Correct 2 ms 6736 KB Output is correct
6 Correct 2 ms 6736 KB Output is correct
7 Correct 2 ms 6736 KB Output is correct
8 Correct 2 ms 6736 KB Output is correct
9 Correct 3 ms 9296 KB Output is correct
10 Correct 2 ms 6736 KB Output is correct
11 Correct 2 ms 6736 KB Output is correct
12 Correct 5 ms 9808 KB Output is correct
13 Correct 5 ms 9820 KB Output is correct
14 Correct 2 ms 6736 KB Output is correct
15 Correct 2 ms 6736 KB Output is correct
16 Correct 460 ms 87344 KB Output is correct
17 Correct 51 ms 18636 KB Output is correct
18 Correct 70 ms 24136 KB Output is correct
19 Correct 537 ms 90284 KB Output is correct
20 Correct 329 ms 78200 KB Output is correct
21 Correct 29 ms 14928 KB Output is correct
22 Correct 297 ms 55748 KB Output is correct