답안 #618661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618661 2022-08-02T06:27:54 Z Mohammed_Atalah 경주 (Race) (IOI11_race) C++17
21 / 100
3000 ms 18252 KB
#include "race.h"
#include <bits/stdc++.h>

using namespace std;
vector<vector<vector<int>>> edg;
int curr = 0;
int r = 0;
int mn = 1e9;
bool found = 0;
int  k;
vector<int> vis;
void dfs(int idx) {
  if (curr == k) {
    mn = min(r, mn);
    found = 1;
    return;
  }
  for (auto &i : edg[idx]) {
    if (!vis[i[0]]) {
      vis[i[0]] = 1;
      curr += i[1];
      r++;
      dfs(i[0]);
      r--;
      curr -= i[1];
      vis[i[0]] = 0;
    }
  }
}

int best_path(int N, int K, int H[][2], int L[])
{
  k = K;
  edg.resize(N);
  vis.resize(N);
  for (int i = 0 ; i < N - 1; i++) {
    edg[H[i][0]].push_back({H[i][1], L[i]});
    edg[H[i][1]].push_back({H[i][0], L[i]});
  }

  for (int i = 0; i < N; i++) {
    vis[i] = 1;
    dfs(i);
    vis[i] = 0;
  }
  return ((found) ? mn : -1);
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 21 ms 496 KB Output is correct
22 Correct 25 ms 500 KB Output is correct
23 Correct 23 ms 500 KB Output is correct
24 Correct 24 ms 500 KB Output is correct
25 Correct 23 ms 496 KB Output is correct
26 Correct 23 ms 468 KB Output is correct
27 Correct 25 ms 468 KB Output is correct
28 Correct 25 ms 496 KB Output is correct
29 Correct 23 ms 468 KB Output is correct
30 Correct 25 ms 468 KB Output is correct
31 Correct 23 ms 448 KB Output is correct
32 Correct 22 ms 472 KB Output is correct
33 Correct 23 ms 468 KB Output is correct
34 Correct 17 ms 484 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 14 ms 476 KB Output is correct
37 Correct 15 ms 476 KB Output is correct
38 Correct 19 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Execution timed out 3068 ms 18252 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 308 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 308 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 21 ms 496 KB Output is correct
22 Correct 25 ms 500 KB Output is correct
23 Correct 23 ms 500 KB Output is correct
24 Correct 24 ms 500 KB Output is correct
25 Correct 23 ms 496 KB Output is correct
26 Correct 23 ms 468 KB Output is correct
27 Correct 25 ms 468 KB Output is correct
28 Correct 25 ms 496 KB Output is correct
29 Correct 23 ms 468 KB Output is correct
30 Correct 25 ms 468 KB Output is correct
31 Correct 23 ms 448 KB Output is correct
32 Correct 22 ms 472 KB Output is correct
33 Correct 23 ms 468 KB Output is correct
34 Correct 17 ms 484 KB Output is correct
35 Correct 16 ms 468 KB Output is correct
36 Correct 14 ms 476 KB Output is correct
37 Correct 15 ms 476 KB Output is correct
38 Correct 19 ms 468 KB Output is correct
39 Execution timed out 3068 ms 18252 KB Time limit exceeded
40 Halted 0 ms 0 KB -