Submission #989652

# Submission time Handle Problem Language Result Execution time Memory
989652 2024-05-28T13:19:16 Z mindiyak Race (IOI11_race) C++14
21 / 100
3000 ms 24896 KB
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<ld> vd;
typedef vector<long> vl;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fst first
#define nl endl
#define sec second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;

#include "race.h"

vvpi paths(2e5+5);
int ans = 1e8;
bool solved = false;

void dfs(int pos,vi visited,int cost,int K,int path){
  if(visited[pos])return;
  visited[pos] = 1;

  if(cost > K)return;
  if(cost == K){
    ans = min(ans,path);
    solved = true;
    return;
  }

  for(auto a:paths[pos]){
    dfs(a.fst,visited,cost+a.sec,K,path+1);
  }

}

int best_path(int N, int K, int H[][2], int L[])
{
  ans = 1e8;
  paths = vvpi(2e5+5);
  solved = false;
  FOR(i,0,N-1){
    paths[H[i][0]].pb({H[i][1],L[i]});
    paths[H[i][1]].pb({H[i][0],L[i]});
  }

  FOR(i,0,N){
    vi visited(N,0);
    dfs(i,visited,0,K,0);
  }
  
  if(solved){
    return ans;
  }
  return -1;
}

# Verdict Execution time Memory Grader output
1 Correct 3 ms 11868 KB Output is correct
2 Correct 2 ms 11868 KB Output is correct
3 Correct 3 ms 11776 KB Output is correct
4 Correct 3 ms 11868 KB Output is correct
5 Correct 3 ms 11868 KB Output is correct
6 Correct 3 ms 11868 KB Output is correct
7 Correct 2 ms 11868 KB Output is correct
8 Correct 3 ms 11868 KB Output is correct
9 Correct 3 ms 11868 KB Output is correct
10 Correct 3 ms 11868 KB Output is correct
11 Correct 3 ms 11868 KB Output is correct
12 Correct 3 ms 11868 KB Output is correct
13 Correct 3 ms 11868 KB Output is correct
14 Correct 3 ms 11868 KB Output is correct
15 Correct 3 ms 11868 KB Output is correct
16 Correct 3 ms 11868 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 3 ms 11800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11868 KB Output is correct
2 Correct 2 ms 11868 KB Output is correct
3 Correct 3 ms 11776 KB Output is correct
4 Correct 3 ms 11868 KB Output is correct
5 Correct 3 ms 11868 KB Output is correct
6 Correct 3 ms 11868 KB Output is correct
7 Correct 2 ms 11868 KB Output is correct
8 Correct 3 ms 11868 KB Output is correct
9 Correct 3 ms 11868 KB Output is correct
10 Correct 3 ms 11868 KB Output is correct
11 Correct 3 ms 11868 KB Output is correct
12 Correct 3 ms 11868 KB Output is correct
13 Correct 3 ms 11868 KB Output is correct
14 Correct 3 ms 11868 KB Output is correct
15 Correct 3 ms 11868 KB Output is correct
16 Correct 3 ms 11868 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 3 ms 11800 KB Output is correct
19 Correct 3 ms 11868 KB Output is correct
20 Correct 3 ms 11868 KB Output is correct
21 Correct 205 ms 11868 KB Output is correct
22 Correct 4 ms 11868 KB Output is correct
23 Correct 4 ms 11868 KB Output is correct
24 Correct 5 ms 11868 KB Output is correct
25 Correct 154 ms 11864 KB Output is correct
26 Correct 5 ms 11868 KB Output is correct
27 Correct 3 ms 11820 KB Output is correct
28 Correct 36 ms 11868 KB Output is correct
29 Correct 80 ms 11864 KB Output is correct
30 Correct 99 ms 11868 KB Output is correct
31 Correct 146 ms 11868 KB Output is correct
32 Correct 154 ms 11864 KB Output is correct
33 Correct 125 ms 11868 KB Output is correct
34 Correct 12 ms 11868 KB Output is correct
35 Correct 13 ms 11868 KB Output is correct
36 Correct 14 ms 11868 KB Output is correct
37 Correct 120 ms 11868 KB Output is correct
38 Correct 128 ms 11864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11868 KB Output is correct
2 Correct 2 ms 11868 KB Output is correct
3 Correct 3 ms 11776 KB Output is correct
4 Correct 3 ms 11868 KB Output is correct
5 Correct 3 ms 11868 KB Output is correct
6 Correct 3 ms 11868 KB Output is correct
7 Correct 2 ms 11868 KB Output is correct
8 Correct 3 ms 11868 KB Output is correct
9 Correct 3 ms 11868 KB Output is correct
10 Correct 3 ms 11868 KB Output is correct
11 Correct 3 ms 11868 KB Output is correct
12 Correct 3 ms 11868 KB Output is correct
13 Correct 3 ms 11868 KB Output is correct
14 Correct 3 ms 11868 KB Output is correct
15 Correct 3 ms 11868 KB Output is correct
16 Correct 3 ms 11868 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 3 ms 11800 KB Output is correct
19 Execution timed out 3066 ms 24896 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 11868 KB Output is correct
2 Correct 2 ms 11868 KB Output is correct
3 Correct 3 ms 11776 KB Output is correct
4 Correct 3 ms 11868 KB Output is correct
5 Correct 3 ms 11868 KB Output is correct
6 Correct 3 ms 11868 KB Output is correct
7 Correct 2 ms 11868 KB Output is correct
8 Correct 3 ms 11868 KB Output is correct
9 Correct 3 ms 11868 KB Output is correct
10 Correct 3 ms 11868 KB Output is correct
11 Correct 3 ms 11868 KB Output is correct
12 Correct 3 ms 11868 KB Output is correct
13 Correct 3 ms 11868 KB Output is correct
14 Correct 3 ms 11868 KB Output is correct
15 Correct 3 ms 11868 KB Output is correct
16 Correct 3 ms 11868 KB Output is correct
17 Correct 3 ms 11864 KB Output is correct
18 Correct 3 ms 11800 KB Output is correct
19 Correct 3 ms 11868 KB Output is correct
20 Correct 3 ms 11868 KB Output is correct
21 Correct 205 ms 11868 KB Output is correct
22 Correct 4 ms 11868 KB Output is correct
23 Correct 4 ms 11868 KB Output is correct
24 Correct 5 ms 11868 KB Output is correct
25 Correct 154 ms 11864 KB Output is correct
26 Correct 5 ms 11868 KB Output is correct
27 Correct 3 ms 11820 KB Output is correct
28 Correct 36 ms 11868 KB Output is correct
29 Correct 80 ms 11864 KB Output is correct
30 Correct 99 ms 11868 KB Output is correct
31 Correct 146 ms 11868 KB Output is correct
32 Correct 154 ms 11864 KB Output is correct
33 Correct 125 ms 11868 KB Output is correct
34 Correct 12 ms 11868 KB Output is correct
35 Correct 13 ms 11868 KB Output is correct
36 Correct 14 ms 11868 KB Output is correct
37 Correct 120 ms 11868 KB Output is correct
38 Correct 128 ms 11864 KB Output is correct
39 Execution timed out 3066 ms 24896 KB Time limit exceeded
40 Halted 0 ms 0 KB -