Submission #1000776

# Submission time Handle Problem Language Result Execution time Memory
1000776 2024-06-18T08:36:15 Z ALTAKEXE Race (IOI11_race) C++17
21 / 100
17 ms 9304 KB
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> adj[1010];
int dfs(int x, int p, int rem, int l)
{
  if (rem == 0)
    return l;
  if (rem < 0)
    return 1010;
  int ans = 1010;
  for (auto [y, w] : adj[x])
  {
    if (y == p)
      continue;
    ans = min(ans, dfs(y, x, rem - w, l + 1));
  }
  return ans;
}
int best_path(int n, int k, int h[][2], int l[])
{
  for (int i = 0; i < n - 1; i++)
  {
    adj[h[i][0] + 1].emplace_back(h[i][1] + 1, l[i]);
    adj[h[i][1] + 1].emplace_back(h[i][0] + 1, l[i]);
  }
  int ans = n;
  for (int i = 1; i <= n; i++)
    ans = min(ans, dfs(i, 0, k, 0));
  if (ans >= n)
    return -1;
  else
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 2648 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 6 ms 520 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 360 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2392 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 6 ms 2396 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 7 ms 2648 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 5 ms 2392 KB Output is correct
38 Correct 7 ms 2572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Runtime error 17 ms 9304 KB Execution killed with signal 11
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 0 ms 2648 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 6 ms 520 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 5 ms 360 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 2 ms 2392 KB Output is correct
29 Correct 4 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Correct 6 ms 2396 KB Output is correct
32 Correct 5 ms 348 KB Output is correct
33 Correct 7 ms 2648 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 5 ms 2392 KB Output is correct
38 Correct 7 ms 2572 KB Output is correct
39 Runtime error 17 ms 9304 KB Execution killed with signal 11
40 Halted 0 ms 0 KB -