답안 #693295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
693295 2023-02-02T15:44:54 Z PoonYaPat 꿈 (IOI13_dreaming) C++14
0 / 100
36 ms 12200 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int mmax[100001],dis_min,mmax1,mmax2,mnode;
bool vis[100001];
vector<pii> adj[100001];
vector<int> v;

void dfs1(int x, int par, int root) {
    vis[x]=true;
    for (auto s : adj[x]) {
        if (s.first==par) continue;
        dfs1(s.first,x,root);
        int dis=mmax[s.first]+s.second;

        if (x==root) {

            if (mmax1<=dis) {
                mmax2=mmax1;
                mmax1=dis;
                mnode=s.first;
            } else if (mmax2<=dis) mmax2=dis;

        } else mmax[x]=max(mmax[x],dis);
    }
}

void dfs2(int x, int par, int dis) {
    dis_min=min(dis_min,max(mmax[x],dis));
    for (auto s : adj[x]) if (s.first!=par) dfs2(s.first,x,dis+s.second);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for (int i=0; i<M; ++i) {
        adj[A[i]].push_back(pii(B[i],T[i]));
        adj[B[i]].push_back(pii(A[i],T[i]));
    }
    for (int i=0; i<N; ++i) {
        if (!vis[i]) {
            mmax1=mmax2=0;
            dfs1(i,-1,i);
            dis_min=mmax1;
            for (auto s : adj[i]) {
                if (s.first==mnode) dfs2(mnode,i,mmax2+s.second);
            }
            v.push_back(dis_min);
        }
    }

    sort(v.begin(),v.end(),greater<int>());
    return max(v[0]+v[1]+L,v[1]+v[2]+2*L);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 12200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 12200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 5848 KB Output is correct
2 Correct 16 ms 5836 KB Output is correct
3 Correct 20 ms 5852 KB Output is correct
4 Correct 21 ms 5816 KB Output is correct
5 Correct 17 ms 5820 KB Output is correct
6 Correct 25 ms 6224 KB Output is correct
7 Correct 17 ms 6024 KB Output is correct
8 Correct 18 ms 5748 KB Output is correct
9 Correct 23 ms 5784 KB Output is correct
10 Correct 17 ms 6000 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 4 ms 3408 KB Output is correct
13 Correct 4 ms 3408 KB Output is correct
14 Correct 4 ms 3424 KB Output is correct
15 Correct 4 ms 3408 KB Output is correct
16 Correct 3 ms 3408 KB Output is correct
17 Correct 4 ms 3408 KB Output is correct
18 Correct 4 ms 3408 KB Output is correct
19 Correct 4 ms 3408 KB Output is correct
20 Incorrect 2 ms 2644 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 12200 KB Output isn't correct
2 Halted 0 ms 0 KB -