답안 #102661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
102661 2019-03-26T14:11:07 Z sean9892 두 로봇 (KOI18_robot) C++14
0 / 100
1000 ms 162996 KB
#include<bits/stdc++.h>
using namespace std;

int main(void){
	int n,s,e;
	scanf("%d%d%d",&n,&s,&e);
	map<pair<int,int>,int> adj;
	for(int i=0;i<n-1;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		adj[{a,b}]=adj[{b,a}]=c;
	}
	queue<int> st;
	st.push(s);st.push(0);
	int root[n+1];
	memset(root,0,sizeof(root));
	while(!st.empty()){
		int t=st.front();st.pop();
		int b=st.front();st.pop();
		root[t]=b;
		if(e==t){
			break;
		}
		for(int i=1;i<=n;i++){
			if(!root[i]&&adj[{i,t}]){
				st.push(i);st.push(t);
			}
		}
	}
	int p=e;
	int m=0;
	int rl=0;
	for(;p!=s;p=root[p]){
		int x=adj[{p,root[p]}];
		m=m>x?m:x;
		rl+=x;
	}
	printf("%d",rl-m);
}

Compilation message

robot.cpp: In function 'int main()':
robot.cpp:6: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:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d",&a,&b,&c);
   ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1085 ms 162996 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1073 ms 89388 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 27668 KB Output is correct
2 Correct 126 ms 15608 KB Output is correct
3 Correct 693 ms 46588 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Execution timed out 1081 ms 77336 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 88496 KB Time limit exceeded
2 Halted 0 ms 0 KB -