답안 #223622

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223622 2020-04-15T20:11:08 Z a_player 꿈 (IOI13_dreaming) C++14
0 / 100
63 ms 12536 KB
#include <bits/stdc++.h>
#include "dreaming.h"
#define f first
#define s second

using namespace std;

const int nax=1e5+5;
struct node{
    int a,b,p;
};
vector<pair<int,int> > grafo[nax];
node dp[nax];
bitset<nax> v;
int mini=INT_MAX,pos;
int diam=0;
node max3(node a, int b, int pos){
    if(b>=a.a)return {b,a.a,pos};
    if(b>a.b) return {a.a,b,a.p};
    return a;
}

int dfsb(int n, int a){
    v[n]=1;
    for(auto x:grafo[n]){
        if(x.f==a)continue;
        dp[n]=max3(dp[n],dfsb(x.f,n)+x.s,x.f);
    }
    diam=max(diam,dp[n].a+dp[n].b);
    return dp[n].a;
}
void dfst(int n, int a, int d){
        if(max(d,dp[n].a)<mini){
            mini=max(d,dp[n].a);
            pos=n;
        }
        for(auto x:grafo[n]){
            if(x.f==a)continue;
            int dd=max(d,(x.f!=dp[n].p?dp[n].a:dp[n].b))+x.s;
            dfst(x.f,n,dd);
        }
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]){
    for(int i=0;i<M;i++){
        grafo[A[i]].push_back({B[i],T[i]});
        grafo[B[i]].push_back({A[i],T[i]});
    }
    vector<int> maxes;
    for(int i=0;i<N;i++){
        if(!v[i]){
            dfsb(i,-1);
            dfst(i,-1,0);
            maxes.push_back(mini);
        }
    }
    sort(maxes.begin(),maxes.end(),greater<int>());
    int ans=diam;
    if(maxes.size()>1)ans=max(ans,maxes[0]+maxes[1]+L);
    if(maxes.size()>2)ans=max(ans,maxes[1]+maxes[2]+2*L);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 11640 KB Output is correct
2 Correct 57 ms 12536 KB Output is correct
3 Correct 40 ms 11000 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 12 ms 3584 KB Output is correct
6 Correct 17 ms 4992 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 30 ms 7032 KB Output is correct
9 Correct 38 ms 9208 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 54 ms 10232 KB Output is correct
12 Correct 63 ms 11512 KB Output is correct
13 Incorrect 6 ms 2816 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 11640 KB Output is correct
2 Correct 57 ms 12536 KB Output is correct
3 Correct 40 ms 11000 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 12 ms 3584 KB Output is correct
6 Correct 17 ms 4992 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 30 ms 7032 KB Output is correct
9 Correct 38 ms 9208 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 54 ms 10232 KB Output is correct
12 Correct 63 ms 11512 KB Output is correct
13 Incorrect 6 ms 2816 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 11640 KB Output is correct
2 Correct 57 ms 12536 KB Output is correct
3 Correct 40 ms 11000 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 12 ms 3584 KB Output is correct
6 Correct 17 ms 4992 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 30 ms 7032 KB Output is correct
9 Correct 38 ms 9208 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 54 ms 10232 KB Output is correct
12 Correct 63 ms 11512 KB Output is correct
13 Incorrect 6 ms 2816 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 6520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 11640 KB Output is correct
2 Correct 57 ms 12536 KB Output is correct
3 Correct 40 ms 11000 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 12 ms 3584 KB Output is correct
6 Correct 17 ms 4992 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 30 ms 7032 KB Output is correct
9 Correct 38 ms 9208 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 54 ms 10232 KB Output is correct
12 Correct 63 ms 11512 KB Output is correct
13 Incorrect 6 ms 2816 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 57 ms 11640 KB Output is correct
2 Correct 57 ms 12536 KB Output is correct
3 Correct 40 ms 11000 KB Output is correct
4 Correct 12 ms 4224 KB Output is correct
5 Correct 12 ms 3584 KB Output is correct
6 Correct 17 ms 4992 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 30 ms 7032 KB Output is correct
9 Correct 38 ms 9208 KB Output is correct
10 Correct 6 ms 2816 KB Output is correct
11 Correct 54 ms 10232 KB Output is correct
12 Correct 63 ms 11512 KB Output is correct
13 Incorrect 6 ms 2816 KB Output isn't correct