Submission #63169

# Submission time Handle Problem Language Result Execution time Memory
63169 2018-08-01T02:33:41 Z kjp4155 None (KOI18_robot) C++17
100 / 100
176 ms 59156 KB
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;

int N,A,B;
vector<pair<int,int>> E[100500];

// dist는 루트로부터 해당 정점까지 거리를 저장하는 배열
// mx는 루트로부터 해당 정점까지 경로상 가장 긴 통로의 길이를 저장하는 배열
int D[100500], M[100500];
bool vis[100500];
void dfs(int node, int d, int m){
	D[node] = d;
	M[node] = m;
	vis[node] = true;
	for(pair<int,int> e : E[node]){
		if( !vis[e.first] ) dfs(e.first, d + e.second, max(m, e.second) );
	}
}


int main(){
	scanf("%d%d%d",&N,&A,&B);
	for(int i=1;i<=N-1;i++){
		int x,y,z; scanf("%d%d%d",&x,&y,&z);
		E[x].push_back(make_pair(y,z));
		E[y].push_back(make_pair(x,z));
	}

	dfs(A,0,0);

	printf("%d\n",D[B]-M[B]);
}

Compilation message

robot.cpp: In function 'int main()':
robot.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&N,&A,&B);
  ~~~~~^~~~~~~~~~~~~~~~~~~
robot.cpp:27:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int x,y,z; scanf("%d%d%d",&x,&y,&z);
              ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 79 ms 12896 KB Output is correct
2 Correct 62 ms 13584 KB Output is correct
3 Correct 88 ms 13584 KB Output is correct
4 Correct 7 ms 13584 KB Output is correct
5 Correct 12 ms 13584 KB Output is correct
6 Correct 18 ms 13584 KB Output is correct
7 Correct 4 ms 13584 KB Output is correct
8 Correct 17 ms 13584 KB Output is correct
9 Correct 6 ms 13584 KB Output is correct
10 Correct 20 ms 13584 KB Output is correct
11 Correct 5 ms 13584 KB Output is correct
12 Correct 5 ms 13584 KB Output is correct
13 Correct 22 ms 13584 KB Output is correct
14 Correct 32 ms 13584 KB Output is correct
15 Correct 8 ms 13584 KB Output is correct
16 Correct 33 ms 13584 KB Output is correct
17 Correct 33 ms 14380 KB Output is correct
18 Correct 37 ms 15288 KB Output is correct
19 Correct 10 ms 15288 KB Output is correct
20 Correct 39 ms 16968 KB Output is correct
21 Correct 55 ms 18332 KB Output is correct
22 Correct 59 ms 21632 KB Output is correct
23 Correct 10 ms 21632 KB Output is correct
24 Correct 85 ms 22460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 22800 KB Output is correct
2 Correct 61 ms 25344 KB Output is correct
3 Correct 5 ms 25344 KB Output is correct
4 Correct 6 ms 25344 KB Output is correct
5 Correct 16 ms 25344 KB Output is correct
6 Correct 13 ms 25344 KB Output is correct
7 Correct 4 ms 25344 KB Output is correct
8 Correct 26 ms 25344 KB Output is correct
9 Correct 19 ms 25344 KB Output is correct
10 Correct 7 ms 25344 KB Output is correct
11 Correct 27 ms 25344 KB Output is correct
12 Correct 39 ms 25344 KB Output is correct
13 Correct 9 ms 25344 KB Output is correct
14 Correct 7 ms 25344 KB Output is correct
15 Correct 56 ms 25344 KB Output is correct
16 Correct 43 ms 26040 KB Output is correct
17 Correct 57 ms 27528 KB Output is correct
18 Correct 43 ms 27528 KB Output is correct
19 Correct 50 ms 31808 KB Output is correct
20 Correct 78 ms 31808 KB Output is correct
21 Correct 8 ms 31808 KB Output is correct
22 Correct 10 ms 31808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 31808 KB Output is correct
2 Correct 5 ms 31808 KB Output is correct
3 Correct 7 ms 31808 KB Output is correct
4 Correct 6 ms 31808 KB Output is correct
5 Correct 8 ms 31808 KB Output is correct
6 Correct 7 ms 31808 KB Output is correct
7 Correct 8 ms 31808 KB Output is correct
8 Correct 4 ms 31808 KB Output is correct
9 Correct 5 ms 31808 KB Output is correct
10 Correct 10 ms 31808 KB Output is correct
11 Correct 8 ms 31808 KB Output is correct
12 Correct 10 ms 31808 KB Output is correct
13 Correct 6 ms 31808 KB Output is correct
14 Correct 8 ms 31808 KB Output is correct
15 Correct 8 ms 31808 KB Output is correct
16 Correct 6 ms 31808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 33760 KB Output is correct
2 Correct 133 ms 35064 KB Output is correct
3 Correct 79 ms 40288 KB Output is correct
4 Correct 92 ms 40796 KB Output is correct
5 Correct 60 ms 40796 KB Output is correct
6 Correct 176 ms 44752 KB Output is correct
7 Correct 7 ms 44752 KB Output is correct
8 Correct 7 ms 44752 KB Output is correct
9 Correct 5 ms 44752 KB Output is correct
10 Correct 14 ms 44752 KB Output is correct
11 Correct 5 ms 44752 KB Output is correct
12 Correct 16 ms 44752 KB Output is correct
13 Correct 20 ms 44752 KB Output is correct
14 Correct 14 ms 44752 KB Output is correct
15 Correct 6 ms 44752 KB Output is correct
16 Correct 7 ms 44752 KB Output is correct
17 Correct 19 ms 44752 KB Output is correct
18 Correct 7 ms 44752 KB Output is correct
19 Correct 17 ms 44752 KB Output is correct
20 Correct 23 ms 44752 KB Output is correct
21 Correct 24 ms 44752 KB Output is correct
22 Correct 8 ms 44752 KB Output is correct
23 Correct 4 ms 44752 KB Output is correct
24 Correct 4 ms 44752 KB Output is correct
25 Correct 7 ms 44752 KB Output is correct
26 Correct 20 ms 44752 KB Output is correct
27 Correct 8 ms 44752 KB Output is correct
28 Correct 26 ms 44752 KB Output is correct
29 Correct 38 ms 44752 KB Output is correct
30 Correct 56 ms 44752 KB Output is correct
31 Correct 6 ms 44752 KB Output is correct
32 Correct 6 ms 44752 KB Output is correct
33 Correct 7 ms 44752 KB Output is correct
34 Correct 32 ms 44752 KB Output is correct
35 Correct 8 ms 44752 KB Output is correct
36 Correct 51 ms 44752 KB Output is correct
37 Correct 47 ms 45036 KB Output is correct
38 Correct 37 ms 46804 KB Output is correct
39 Correct 11 ms 46804 KB Output is correct
40 Correct 6 ms 46804 KB Output is correct
41 Correct 43 ms 47840 KB Output is correct
42 Correct 12 ms 47840 KB Output is correct
43 Correct 40 ms 49284 KB Output is correct
44 Correct 47 ms 49284 KB Output is correct
45 Correct 45 ms 49960 KB Output is correct
46 Correct 57 ms 52632 KB Output is correct
47 Correct 59 ms 55728 KB Output is correct
48 Correct 103 ms 55728 KB Output is correct
49 Correct 94 ms 55728 KB Output is correct
50 Correct 11 ms 55728 KB Output is correct
51 Correct 13 ms 55728 KB Output is correct
52 Correct 12 ms 55728 KB Output is correct
53 Correct 84 ms 59156 KB Output is correct