답안 #64205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
64205 2018-08-03T13:38:49 Z gs14004 두 로봇 (KOI18_robot) C++17
100 / 100
148 ms 59748 KB
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 255555;

vector<pi> gph[MAXN];
vector<int> v;
int n, s, e;
int par[MAXN], pae[MAXN];

void dfs(int x, int p){
	for(auto &i : gph[x]){
		if(i.second != p){
			par[i.second] = x;
			pae[i.second] = i.first;
			dfs(i.second, x);
		}
	}
}

int main(){
	scanf("%d %d %d",&n,&s,&e);
	if(s == e){
		puts("0");
		return 0;
	}
	for(int i=0; i<n-1; i++){
		int x, y, v;
		scanf("%d %d %d",&x,&y,&v);
		gph[x].push_back(pi(v, y));
		gph[y].push_back(pi(v, x));
	}
	dfs(s, -1);
	while(e != s){
		v.push_back(pae[e]);
		e = par[e];
	}
	cout << accumulate(v.begin(), v.end(), 0) - *max_element(v.begin(), v.end()) << endl;
}

Compilation message

robot.cpp: In function 'int main()':
robot.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&s,&e);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
robot.cpp:30:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&x,&y,&v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 17144 KB Output is correct
2 Correct 8 ms 17144 KB Output is correct
3 Correct 76 ms 17144 KB Output is correct
4 Correct 8 ms 17144 KB Output is correct
5 Correct 14 ms 17144 KB Output is correct
6 Correct 15 ms 17144 KB Output is correct
7 Correct 8 ms 17144 KB Output is correct
8 Correct 23 ms 17144 KB Output is correct
9 Correct 10 ms 17144 KB Output is correct
10 Correct 27 ms 17144 KB Output is correct
11 Correct 8 ms 17144 KB Output is correct
12 Correct 7 ms 17144 KB Output is correct
13 Correct 23 ms 17144 KB Output is correct
14 Correct 31 ms 17144 KB Output is correct
15 Correct 11 ms 17144 KB Output is correct
16 Correct 36 ms 17144 KB Output is correct
17 Correct 35 ms 17144 KB Output is correct
18 Correct 42 ms 17548 KB Output is correct
19 Correct 15 ms 17548 KB Output is correct
20 Correct 39 ms 19052 KB Output is correct
21 Correct 47 ms 20676 KB Output is correct
22 Correct 50 ms 23712 KB Output is correct
23 Correct 13 ms 23712 KB Output is correct
24 Correct 69 ms 24404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 102 ms 25004 KB Output is correct
2 Correct 68 ms 27544 KB Output is correct
3 Correct 9 ms 27544 KB Output is correct
4 Correct 8 ms 27544 KB Output is correct
5 Correct 19 ms 27544 KB Output is correct
6 Correct 16 ms 27544 KB Output is correct
7 Correct 8 ms 27544 KB Output is correct
8 Correct 20 ms 27544 KB Output is correct
9 Correct 21 ms 27544 KB Output is correct
10 Correct 8 ms 27544 KB Output is correct
11 Correct 31 ms 27544 KB Output is correct
12 Correct 34 ms 27544 KB Output is correct
13 Correct 12 ms 27544 KB Output is correct
14 Correct 12 ms 27544 KB Output is correct
15 Correct 40 ms 27544 KB Output is correct
16 Correct 41 ms 28492 KB Output is correct
17 Correct 49 ms 29728 KB Output is correct
18 Correct 59 ms 29728 KB Output is correct
19 Correct 61 ms 34160 KB Output is correct
20 Correct 100 ms 34160 KB Output is correct
21 Correct 13 ms 34160 KB Output is correct
22 Correct 18 ms 34160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 34160 KB Output is correct
2 Correct 11 ms 34160 KB Output is correct
3 Correct 11 ms 34160 KB Output is correct
4 Correct 9 ms 34160 KB Output is correct
5 Correct 9 ms 34160 KB Output is correct
6 Correct 10 ms 34160 KB Output is correct
7 Correct 10 ms 34160 KB Output is correct
8 Correct 10 ms 34160 KB Output is correct
9 Correct 8 ms 34160 KB Output is correct
10 Correct 9 ms 34160 KB Output is correct
11 Correct 9 ms 34160 KB Output is correct
12 Correct 9 ms 34160 KB Output is correct
13 Correct 8 ms 34160 KB Output is correct
14 Correct 11 ms 34160 KB Output is correct
15 Correct 12 ms 34160 KB Output is correct
16 Correct 8 ms 34160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 35736 KB Output is correct
2 Correct 115 ms 37160 KB Output is correct
3 Correct 66 ms 42860 KB Output is correct
4 Correct 8 ms 42860 KB Output is correct
5 Correct 66 ms 42860 KB Output is correct
6 Correct 148 ms 45684 KB Output is correct
7 Correct 8 ms 45684 KB Output is correct
8 Correct 8 ms 45684 KB Output is correct
9 Correct 10 ms 45684 KB Output is correct
10 Correct 18 ms 45684 KB Output is correct
11 Correct 9 ms 45684 KB Output is correct
12 Correct 22 ms 45684 KB Output is correct
13 Correct 22 ms 45684 KB Output is correct
14 Correct 20 ms 45684 KB Output is correct
15 Correct 9 ms 45684 KB Output is correct
16 Correct 9 ms 45684 KB Output is correct
17 Correct 19 ms 45684 KB Output is correct
18 Correct 11 ms 45684 KB Output is correct
19 Correct 25 ms 45684 KB Output is correct
20 Correct 25 ms 45684 KB Output is correct
21 Correct 25 ms 45684 KB Output is correct
22 Correct 9 ms 45684 KB Output is correct
23 Correct 8 ms 45684 KB Output is correct
24 Correct 8 ms 45684 KB Output is correct
25 Correct 9 ms 45684 KB Output is correct
26 Correct 33 ms 45684 KB Output is correct
27 Correct 9 ms 45684 KB Output is correct
28 Correct 26 ms 45684 KB Output is correct
29 Correct 33 ms 45684 KB Output is correct
30 Correct 43 ms 45684 KB Output is correct
31 Correct 12 ms 45684 KB Output is correct
32 Correct 9 ms 45684 KB Output is correct
33 Correct 10 ms 45684 KB Output is correct
34 Correct 31 ms 45684 KB Output is correct
35 Correct 10 ms 45684 KB Output is correct
36 Correct 60 ms 45684 KB Output is correct
37 Correct 59 ms 45684 KB Output is correct
38 Correct 38 ms 47596 KB Output is correct
39 Correct 12 ms 47596 KB Output is correct
40 Correct 9 ms 47596 KB Output is correct
41 Correct 45 ms 48492 KB Output is correct
42 Correct 14 ms 48492 KB Output is correct
43 Correct 53 ms 49936 KB Output is correct
44 Correct 68 ms 49936 KB Output is correct
45 Correct 48 ms 50484 KB Output is correct
46 Correct 46 ms 53556 KB Output is correct
47 Correct 51 ms 56448 KB Output is correct
48 Correct 95 ms 56448 KB Output is correct
49 Correct 91 ms 56448 KB Output is correct
50 Correct 14 ms 56448 KB Output is correct
51 Correct 14 ms 56448 KB Output is correct
52 Correct 14 ms 56448 KB Output is correct
53 Correct 61 ms 59748 KB Output is correct