답안 #320375

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
320375 2020-11-08T11:59:50 Z keta_tsimakuridze 꿈 (IOI13_dreaming) C++14
14 / 100
86 ms 16100 KB
#include "dreaming.h"
#include<bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N=1e5+5;
vector<pair<int,int> > V[N];

int fix[N],st[N],MxR,Mxr,mx,ans,Mx,h[N][2],R;
void dfs(int u,int p,int t){
	fix[u]=1;
	if(h[u][t]>mx) {
		mx=h[u][t]; Mx=u;
	}
	for(int i=0;i<V[u].size();i++){
		if(V[u][i].f!=p) {
			h[V[u][i].f][t]=h[u][t]+V[u][i].s;
			dfs(V[u][i].f,u,t);
		}
	}
}
void dfs1(int u,int p){
	R=min(R,max(h[u][0],h[u][1]));
	for(int i=0;i<V[u].size();i++){
		if(V[u][i].f!=p){
			dfs1(V[u][i].f,u);
		
		}
	}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    
    for(int i=0;i<M;i++){
    	V[A[i]].push_back({B[i],T[i]});
    	V[B[i]].push_back({A[i],T[i]});
	}
	for(int i=0;i<N;i++){
		if(!fix[i]){
			
			mx=0;
			dfs(i,-1,0);
			mx=0; R=N;
		//	mx1=Mx;
	
		     h[Mx][0]=0;
			dfs(Mx,-1,0);	
			ans=max(ans,mx);
			dfs(Mx,-1,1);
			dfs1(i,-1);
			if(MxR<R){
				swap(MxR,Mxr);
				MxR=R;
			}
			else if(Mxr<R){
				Mxr=R;
			}
			
		}
	}
	ans=max(ans,MxR+Mxr+L);
	return ans;
}/*
int main() {
	int N, M, L, i;
	int res;
	cin>>N>>M>>L;
	for (i = 0; i < M; i++)
		cin>>A[i]>>B[i]>>T[i];

	int answer = travelTime(N, M, L, A, B, T);
	printf("%d\n", answer);

	return 0;
} */

Compilation message

dreaming.cpp: In function 'void dfs(int, int, int)':
dreaming.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
dreaming.cpp: In function 'void dfs1(int, int)':
dreaming.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 16100 KB Output is correct
2 Correct 62 ms 15972 KB Output is correct
3 Correct 39 ms 11620 KB Output is correct
4 Correct 9 ms 4716 KB Output is correct
5 Correct 8 ms 3820 KB Output is correct
6 Correct 15 ms 5612 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 29 ms 7268 KB Output is correct
9 Correct 40 ms 9252 KB Output is correct
10 Correct 2 ms 2816 KB Output is correct
11 Correct 65 ms 11364 KB Output is correct
12 Correct 86 ms 13668 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 16100 KB Output is correct
2 Correct 62 ms 15972 KB Output is correct
3 Correct 39 ms 11620 KB Output is correct
4 Correct 9 ms 4716 KB Output is correct
5 Correct 8 ms 3820 KB Output is correct
6 Correct 15 ms 5612 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 29 ms 7268 KB Output is correct
9 Correct 40 ms 9252 KB Output is correct
10 Correct 2 ms 2816 KB Output is correct
11 Correct 65 ms 11364 KB Output is correct
12 Correct 86 ms 13668 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2668 KB Output is correct
17 Incorrect 2 ms 2668 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 16100 KB Output is correct
2 Correct 62 ms 15972 KB Output is correct
3 Correct 39 ms 11620 KB Output is correct
4 Correct 9 ms 4716 KB Output is correct
5 Correct 8 ms 3820 KB Output is correct
6 Correct 15 ms 5612 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 29 ms 7268 KB Output is correct
9 Correct 40 ms 9252 KB Output is correct
10 Correct 2 ms 2816 KB Output is correct
11 Correct 65 ms 11364 KB Output is correct
12 Correct 86 ms 13668 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2668 KB Output is correct
17 Incorrect 2 ms 2668 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 6636 KB Output is correct
2 Incorrect 39 ms 6636 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 16100 KB Output is correct
2 Correct 62 ms 15972 KB Output is correct
3 Correct 39 ms 11620 KB Output is correct
4 Correct 9 ms 4716 KB Output is correct
5 Correct 8 ms 3820 KB Output is correct
6 Correct 15 ms 5612 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 29 ms 7268 KB Output is correct
9 Correct 40 ms 9252 KB Output is correct
10 Correct 2 ms 2816 KB Output is correct
11 Correct 65 ms 11364 KB Output is correct
12 Correct 86 ms 13668 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2796 KB Output is correct
15 Correct 3 ms 2796 KB Output is correct
16 Correct 3 ms 2924 KB Output is correct
17 Incorrect 2 ms 2796 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 16100 KB Output is correct
2 Correct 62 ms 15972 KB Output is correct
3 Correct 39 ms 11620 KB Output is correct
4 Correct 9 ms 4716 KB Output is correct
5 Correct 8 ms 3820 KB Output is correct
6 Correct 15 ms 5612 KB Output is correct
7 Correct 2 ms 2668 KB Output is correct
8 Correct 29 ms 7268 KB Output is correct
9 Correct 40 ms 9252 KB Output is correct
10 Correct 2 ms 2816 KB Output is correct
11 Correct 65 ms 11364 KB Output is correct
12 Correct 86 ms 13668 KB Output is correct
13 Correct 2 ms 2796 KB Output is correct
14 Correct 2 ms 2668 KB Output is correct
15 Correct 2 ms 2668 KB Output is correct
16 Correct 2 ms 2668 KB Output is correct
17 Incorrect 2 ms 2668 KB Output isn't correct
18 Halted 0 ms 0 KB -