Submission #63170

# Submission time Handle Problem Language Result Execution time Memory
63170 2018-08-01T02:34:57 Z kjp4155 None (KOI18_robot) C++17
100 / 100
171 ms 11644 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 dist[100500], mx[100500];
bool vis[100500];
void dfs(int node, int d, int m){
	dist[node] = d;
	mx[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",dist[B]-mx[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 59 ms 11384 KB Output is correct
2 Correct 74 ms 11384 KB Output is correct
3 Correct 58 ms 11384 KB Output is correct
4 Correct 5 ms 11384 KB Output is correct
5 Correct 11 ms 11384 KB Output is correct
6 Correct 17 ms 11384 KB Output is correct
7 Correct 5 ms 11384 KB Output is correct
8 Correct 16 ms 11384 KB Output is correct
9 Correct 6 ms 11384 KB Output is correct
10 Correct 19 ms 11384 KB Output is correct
11 Correct 5 ms 11384 KB Output is correct
12 Correct 5 ms 11384 KB Output is correct
13 Correct 28 ms 11384 KB Output is correct
14 Correct 28 ms 11384 KB Output is correct
15 Correct 8 ms 11384 KB Output is correct
16 Correct 43 ms 11384 KB Output is correct
17 Correct 38 ms 11384 KB Output is correct
18 Correct 43 ms 11384 KB Output is correct
19 Correct 8 ms 11384 KB Output is correct
20 Correct 49 ms 11384 KB Output is correct
21 Correct 58 ms 11384 KB Output is correct
22 Correct 82 ms 11384 KB Output is correct
23 Correct 10 ms 11384 KB Output is correct
24 Correct 55 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 137 ms 11384 KB Output is correct
2 Correct 61 ms 11384 KB Output is correct
3 Correct 5 ms 11384 KB Output is correct
4 Correct 8 ms 11384 KB Output is correct
5 Correct 18 ms 11384 KB Output is correct
6 Correct 14 ms 11384 KB Output is correct
7 Correct 6 ms 11384 KB Output is correct
8 Correct 20 ms 11384 KB Output is correct
9 Correct 29 ms 11384 KB Output is correct
10 Correct 5 ms 11384 KB Output is correct
11 Correct 37 ms 11384 KB Output is correct
12 Correct 47 ms 11384 KB Output is correct
13 Correct 8 ms 11384 KB Output is correct
14 Correct 7 ms 11384 KB Output is correct
15 Correct 71 ms 11384 KB Output is correct
16 Correct 46 ms 11384 KB Output is correct
17 Correct 52 ms 11384 KB Output is correct
18 Correct 76 ms 11384 KB Output is correct
19 Correct 57 ms 11384 KB Output is correct
20 Correct 107 ms 11384 KB Output is correct
21 Correct 10 ms 11384 KB Output is correct
22 Correct 11 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 11384 KB Output is correct
2 Correct 5 ms 11384 KB Output is correct
3 Correct 8 ms 11384 KB Output is correct
4 Correct 4 ms 11384 KB Output is correct
5 Correct 6 ms 11384 KB Output is correct
6 Correct 7 ms 11384 KB Output is correct
7 Correct 7 ms 11384 KB Output is correct
8 Correct 6 ms 11384 KB Output is correct
9 Correct 5 ms 11384 KB Output is correct
10 Correct 8 ms 11384 KB Output is correct
11 Correct 6 ms 11384 KB Output is correct
12 Correct 9 ms 11384 KB Output is correct
13 Correct 8 ms 11384 KB Output is correct
14 Correct 8 ms 11384 KB Output is correct
15 Correct 7 ms 11384 KB Output is correct
16 Correct 7 ms 11384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 171 ms 11384 KB Output is correct
2 Correct 133 ms 11384 KB Output is correct
3 Correct 68 ms 11608 KB Output is correct
4 Correct 71 ms 11608 KB Output is correct
5 Correct 65 ms 11608 KB Output is correct
6 Correct 148 ms 11644 KB Output is correct
7 Correct 4 ms 11644 KB Output is correct
8 Correct 7 ms 11644 KB Output is correct
9 Correct 7 ms 11644 KB Output is correct
10 Correct 14 ms 11644 KB Output is correct
11 Correct 8 ms 11644 KB Output is correct
12 Correct 16 ms 11644 KB Output is correct
13 Correct 26 ms 11644 KB Output is correct
14 Correct 20 ms 11644 KB Output is correct
15 Correct 5 ms 11644 KB Output is correct
16 Correct 8 ms 11644 KB Output is correct
17 Correct 18 ms 11644 KB Output is correct
18 Correct 6 ms 11644 KB Output is correct
19 Correct 18 ms 11644 KB Output is correct
20 Correct 23 ms 11644 KB Output is correct
21 Correct 18 ms 11644 KB Output is correct
22 Correct 7 ms 11644 KB Output is correct
23 Correct 4 ms 11644 KB Output is correct
24 Correct 5 ms 11644 KB Output is correct
25 Correct 7 ms 11644 KB Output is correct
26 Correct 23 ms 11644 KB Output is correct
27 Correct 6 ms 11644 KB Output is correct
28 Correct 24 ms 11644 KB Output is correct
29 Correct 40 ms 11644 KB Output is correct
30 Correct 42 ms 11644 KB Output is correct
31 Correct 7 ms 11644 KB Output is correct
32 Correct 8 ms 11644 KB Output is correct
33 Correct 8 ms 11644 KB Output is correct
34 Correct 46 ms 11644 KB Output is correct
35 Correct 9 ms 11644 KB Output is correct
36 Correct 61 ms 11644 KB Output is correct
37 Correct 48 ms 11644 KB Output is correct
38 Correct 36 ms 11644 KB Output is correct
39 Correct 8 ms 11644 KB Output is correct
40 Correct 5 ms 11644 KB Output is correct
41 Correct 36 ms 11644 KB Output is correct
42 Correct 9 ms 11644 KB Output is correct
43 Correct 42 ms 11644 KB Output is correct
44 Correct 46 ms 11644 KB Output is correct
45 Correct 44 ms 11644 KB Output is correct
46 Correct 48 ms 11644 KB Output is correct
47 Correct 53 ms 11644 KB Output is correct
48 Correct 104 ms 11644 KB Output is correct
49 Correct 102 ms 11644 KB Output is correct
50 Correct 11 ms 11644 KB Output is correct
51 Correct 11 ms 11644 KB Output is correct
52 Correct 13 ms 11644 KB Output is correct
53 Correct 57 ms 11644 KB Output is correct