Submission #792304

# Submission time Handle Problem Language Result Execution time Memory
792304 2023-07-25T00:38:56 Z limabeans Race (IOI11_race) C++17
21 / 100
3000 ms 12524 KB
#include <algorithm>
#include <iostream>
#include <vector>
#include <cassert>


using namespace std;
using ll = long long;
const int maxn=2e5+10;


vector<pair<ll,int>> g[maxn];

pair<ll,int> dfs(int at, int p, int dst) {
  if (at==dst) {
    return {0,0};
  }
  for (auto ed: g[at]) {
    int to = ed.second;
    if (to==p) continue;
    auto cur = dfs(to, at, dst);
    if (cur.second != -1) {
      cur.first += ed.first;
      cur.second++;
      return cur;
    }
  }
  return {0,-1};
}

int best_path(int n, int k, int H[][2], int L[]) {
  for (int i=0; i<n-1; i++) {
    int u=H[i][0];
    int v=H[i][1];
    int w=L[i];
    g[v].push_back({w,u});
    g[u].push_back({w,v});
  }

  int best=n;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      pair<ll,int> cur = dfs(i,i,j);
      if (cur.first == k) {
	best = min(best, cur.second);
      }
    }
  }
  return (best == n ? -1 : best);
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 5 ms 4948 KB Output is correct
3 Correct 4 ms 5000 KB Output is correct
4 Correct 5 ms 5008 KB Output is correct
5 Correct 5 ms 4948 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 5 ms 5008 KB Output is correct
11 Correct 4 ms 5008 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 4 ms 4948 KB Output is correct
14 Correct 4 ms 5008 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5008 KB Output is correct
18 Correct 5 ms 5008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 5 ms 4948 KB Output is correct
3 Correct 4 ms 5000 KB Output is correct
4 Correct 5 ms 5008 KB Output is correct
5 Correct 5 ms 4948 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 5 ms 5008 KB Output is correct
11 Correct 4 ms 5008 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 4 ms 4948 KB Output is correct
14 Correct 4 ms 5008 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5008 KB Output is correct
18 Correct 5 ms 5008 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 1339 ms 5068 KB Output is correct
22 Correct 1517 ms 5088 KB Output is correct
23 Correct 1517 ms 5072 KB Output is correct
24 Correct 1332 ms 5072 KB Output is correct
25 Correct 1352 ms 5080 KB Output is correct
26 Correct 1382 ms 5076 KB Output is correct
27 Correct 1357 ms 5076 KB Output is correct
28 Correct 1355 ms 5076 KB Output is correct
29 Correct 1319 ms 5076 KB Output is correct
30 Correct 1336 ms 5068 KB Output is correct
31 Correct 1329 ms 5076 KB Output is correct
32 Correct 1342 ms 5076 KB Output is correct
33 Correct 1511 ms 5076 KB Output is correct
34 Correct 1452 ms 5080 KB Output is correct
35 Correct 1289 ms 5076 KB Output is correct
36 Correct 1022 ms 5096 KB Output is correct
37 Correct 1010 ms 5076 KB Output is correct
38 Correct 1432 ms 5076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 5 ms 4948 KB Output is correct
3 Correct 4 ms 5000 KB Output is correct
4 Correct 5 ms 5008 KB Output is correct
5 Correct 5 ms 4948 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 5 ms 5008 KB Output is correct
11 Correct 4 ms 5008 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 4 ms 4948 KB Output is correct
14 Correct 4 ms 5008 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5008 KB Output is correct
18 Correct 5 ms 5008 KB Output is correct
19 Execution timed out 3061 ms 12524 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4948 KB Output is correct
2 Correct 5 ms 4948 KB Output is correct
3 Correct 4 ms 5000 KB Output is correct
4 Correct 5 ms 5008 KB Output is correct
5 Correct 5 ms 4948 KB Output is correct
6 Correct 5 ms 5008 KB Output is correct
7 Correct 4 ms 4948 KB Output is correct
8 Correct 4 ms 4948 KB Output is correct
9 Correct 4 ms 5016 KB Output is correct
10 Correct 5 ms 5008 KB Output is correct
11 Correct 4 ms 5008 KB Output is correct
12 Correct 5 ms 4948 KB Output is correct
13 Correct 4 ms 4948 KB Output is correct
14 Correct 4 ms 5008 KB Output is correct
15 Correct 6 ms 5076 KB Output is correct
16 Correct 4 ms 4948 KB Output is correct
17 Correct 4 ms 5008 KB Output is correct
18 Correct 5 ms 5008 KB Output is correct
19 Correct 2 ms 4948 KB Output is correct
20 Correct 4 ms 4948 KB Output is correct
21 Correct 1339 ms 5068 KB Output is correct
22 Correct 1517 ms 5088 KB Output is correct
23 Correct 1517 ms 5072 KB Output is correct
24 Correct 1332 ms 5072 KB Output is correct
25 Correct 1352 ms 5080 KB Output is correct
26 Correct 1382 ms 5076 KB Output is correct
27 Correct 1357 ms 5076 KB Output is correct
28 Correct 1355 ms 5076 KB Output is correct
29 Correct 1319 ms 5076 KB Output is correct
30 Correct 1336 ms 5068 KB Output is correct
31 Correct 1329 ms 5076 KB Output is correct
32 Correct 1342 ms 5076 KB Output is correct
33 Correct 1511 ms 5076 KB Output is correct
34 Correct 1452 ms 5080 KB Output is correct
35 Correct 1289 ms 5076 KB Output is correct
36 Correct 1022 ms 5096 KB Output is correct
37 Correct 1010 ms 5076 KB Output is correct
38 Correct 1432 ms 5076 KB Output is correct
39 Execution timed out 3061 ms 12524 KB Time limit exceeded
40 Halted 0 ms 0 KB -