답안 #575623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
575623 2022-06-11T06:54:59 Z web 경주 (Race) (IOI11_race) C++17
21 / 100
3000 ms 10284 KB
#include <iostream>
#include <climits>
#include "race.h"
#include <vector>
#include <bitset>
#include <algorithm>
using namespace std;

vector<vector<pair<int, long long>>> adjList;

int DFS(int currNode, int parentNode, int costUsed, int depth, int K)
{
  //cout<<"curr node "<<currNode<<endl;
  if(costUsed == K)
    return depth;
  if(costUsed > K)
    return -1;
  int bestL = INT_MAX;
  for(auto node : adjList[currNode])
  {
  
  
   //cout<<"child: "<<node.first<<endl; 
    if(node.first == parentNode)
      continue;
    int l = DFS(node.first, currNode, costUsed+node.second, depth+1, K);
    //cout<<"l = "<<l<<endl;
    if(l < bestL && l!= -1)
      {bestL = l;
        //cout<<"new best L"<<endl;
      }
  }
  if(bestL ==INT_MAX)
    return -1;
  return bestL;
}

int best_path(int N, int K, int H[][2], int L[])
{
  adjList.resize(N);
  for(int i  =0; i<N-1; ++i)
  {
    adjList[H[i][0]].push_back({H[i][1], L[i]});
    adjList[H[i][1]].push_back({H[i][0], L[i]});
  }
  ////cout<<"here"<<endl;
  int bestPath = INT_MAX;
  for(int i  =0 ; i<N; ++i)
  {
      int l  = DFS(i, -1, 0, 0, K);
      //////cout<<"DFS sur"<<endl;
      if(l != -1 && l < bestPath)
        bestPath = l;
  }
  ////cout<<"there"<<endl;
  if(bestPath == INT_MAX)
    return -1;
  return bestPath;
}

# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 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 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 15 ms 340 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 14 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 4 ms 320 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 9 ms 340 KB Output is correct
31 Correct 14 ms 396 KB Output is correct
32 Correct 14 ms 412 KB Output is correct
33 Correct 13 ms 416 KB Output is correct
34 Correct 2 ms 320 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 7 ms 340 KB Output is correct
38 Correct 8 ms 412 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 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Execution timed out 3005 ms 10284 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 212 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 15 ms 340 KB Output is correct
22 Correct 1 ms 324 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 14 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 4 ms 320 KB Output is correct
29 Correct 8 ms 340 KB Output is correct
30 Correct 9 ms 340 KB Output is correct
31 Correct 14 ms 396 KB Output is correct
32 Correct 14 ms 412 KB Output is correct
33 Correct 13 ms 416 KB Output is correct
34 Correct 2 ms 320 KB Output is correct
35 Correct 2 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 7 ms 340 KB Output is correct
38 Correct 8 ms 412 KB Output is correct
39 Execution timed out 3005 ms 10284 KB Time limit exceeded
40 Halted 0 ms 0 KB -