답안 #441276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
441276 2021-07-04T20:15:24 Z julian33 꿈 (IOI13_dreaming) C++14
0 / 100
53 ms 16452 KB
#include <bits/stdc++.h>
#include "dreaming.h"

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);}

const int mxN=1e5+5;

vector<pii> graph[mxN];
ll dist[mxN];
int ep,seen[mxN];
vector<int> path;

void dfs(int at,int p){
    path.pb(dist[at]);
    seen[at]=1;
    if(dist[at]>dist[ep])
        ep=at;
    for(pii &i:graph[at]){
        if(i.first!=p){
            dist[i.first]=dist[at]+i.second;
            dfs(i.first,at);
        }
    }
}

void merge(pii &a,pii &b,int L){
    if(max(a.first,b.first)>a.second+b.second+L){
        a.first=max(a.first,b.first);
    } else{
        a.first=a.second+b.second+L;
        a.second=max(a.second,b.second)+L;
    }
}

int travelTime(int N,int M,int L,int A[],int B[],int T[]){
    for(int i=0;i<M;i++){
        graph[A[i]].pb({B[i],T[i]});
        graph[B[i]].pb({A[i],T[i]});
    }
    vector<pii> all;
    for(int i=0;i<N;i++){
        if(seen[i])
            continue;
        ep=N;
        dfs(i,-1);
        path.clear();
        dist[ep]=0;
        dfs(ep,-1);
        all.pb({dist[ep],*lower_bound(path.begin(),path.end(),dist[ep]/2)});
        deb(i,all.back().first,all.back().second);
        path.clear();
    }
    pii ans=all[0];
    deb(ans.first,ans.second);
    for(int i=1;i<sz(all);i++){
        merge(ans,all[i],L);
        deb(ans.first,ans.second);
    }
    return ans.first;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 16452 KB Output is correct
2 Correct 53 ms 16428 KB Output is correct
3 Correct 36 ms 11848 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 7 ms 3788 KB Output is correct
6 Correct 13 ms 5792 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 2 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 16452 KB Output is correct
2 Correct 53 ms 16428 KB Output is correct
3 Correct 36 ms 11848 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 7 ms 3788 KB Output is correct
6 Correct 13 ms 5792 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 7120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Incorrect 2 ms 2636 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 16452 KB Output is correct
2 Correct 53 ms 16428 KB Output is correct
3 Correct 36 ms 11848 KB Output is correct
4 Correct 9 ms 4684 KB Output is correct
5 Correct 7 ms 3788 KB Output is correct
6 Correct 13 ms 5792 KB Output is correct
7 Incorrect 2 ms 2636 KB Output isn't correct
8 Halted 0 ms 0 KB -