Submission #914402

# Submission time Handle Problem Language Result Execution time Memory
914402 2024-01-22T02:46:44 Z duckindog Swapping Cities (APIO20_swap) C++14
17 / 100
1946 ms 29240 KB
#include "swap.h"

#include<bits/stdc++.h>

using namespace std;

const int N = 1e3 + 10;
int n, m;
vector<pair<int, int>> ad[N];

void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
  n = N; m = M;
  for (int i = 0; i < m; ++i) {
    int u = U[i], v = V[i], w = W[i];
    ad[u].push_back({v, w});
    ad[v].push_back({u, w});
  }
}

int f[N][N];
void sktra(int x, int y) {
  memset(f, 63, sizeof f);
  using T = tuple<int, int, int>;
  priority_queue<T, vector<T>, greater<T>> q;
  q.emplace(f[x][y] = 0, x, y);
  while (q.size()) {
    int d, x, y; tie(d, x, y) = q.top(); q.pop();
    if (d != f[x][y]) continue;

    for (auto duck : ad[x]) {
      int v, w; tie(v, w) = duck;
      if (v != y && f[v][y] > max(w, d))
        q.emplace(f[v][y] = max(w, d), v, y);
    }

    for (auto duck : ad[y]) {
      int v, w; tie(v, w) = duck;
      if (v != x && f[x][v] > max(w, d))
        q.emplace(f[x][v] = max(w, d), x, v);

    }
  }

}

int getMinimumFuelCapacity(int X, int Y) {
  sktra(X, Y);
  return f[Y][X] > 1e9 ? -1 : f[Y][X];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 58 ms 4992 KB Output is correct
5 Correct 230 ms 6756 KB Output is correct
6 Correct 254 ms 6628 KB Output is correct
7 Correct 341 ms 8912 KB Output is correct
8 Correct 313 ms 5736 KB Output is correct
9 Runtime error 20 ms 4168 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Runtime error 50 ms 7928 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 58 ms 4992 KB Output is correct
5 Correct 230 ms 6756 KB Output is correct
6 Correct 254 ms 6628 KB Output is correct
7 Correct 341 ms 8912 KB Output is correct
8 Correct 313 ms 5736 KB Output is correct
9 Correct 2 ms 4444 KB Output is correct
10 Correct 620 ms 11032 KB Output is correct
11 Correct 645 ms 8648 KB Output is correct
12 Correct 667 ms 10212 KB Output is correct
13 Correct 497 ms 9024 KB Output is correct
14 Correct 571 ms 6812 KB Output is correct
15 Correct 649 ms 5860 KB Output is correct
16 Correct 633 ms 6928 KB Output is correct
17 Correct 648 ms 7196 KB Output is correct
18 Correct 781 ms 11680 KB Output is correct
19 Correct 429 ms 10576 KB Output is correct
20 Correct 677 ms 9476 KB Output is correct
21 Correct 919 ms 15316 KB Output is correct
22 Correct 166 ms 9132 KB Output is correct
23 Correct 540 ms 10296 KB Output is correct
24 Correct 1776 ms 28264 KB Output is correct
25 Correct 1428 ms 17856 KB Output is correct
26 Correct 1946 ms 29176 KB Output is correct
27 Correct 625 ms 7012 KB Output is correct
28 Correct 1730 ms 29240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 58 ms 4992 KB Output is correct
6 Correct 230 ms 6756 KB Output is correct
7 Correct 254 ms 6628 KB Output is correct
8 Correct 341 ms 8912 KB Output is correct
9 Correct 313 ms 5736 KB Output is correct
10 Runtime error 20 ms 4168 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 58 ms 4992 KB Output is correct
5 Correct 230 ms 6756 KB Output is correct
6 Correct 254 ms 6628 KB Output is correct
7 Correct 341 ms 8912 KB Output is correct
8 Correct 313 ms 5736 KB Output is correct
9 Runtime error 20 ms 4168 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 2 ms 4444 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 58 ms 4992 KB Output is correct
6 Correct 230 ms 6756 KB Output is correct
7 Correct 254 ms 6628 KB Output is correct
8 Correct 341 ms 8912 KB Output is correct
9 Correct 313 ms 5736 KB Output is correct
10 Runtime error 20 ms 4168 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -