답안 #305934

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305934 2020-09-24T06:03:54 Z juggernaut 꿈 (IOI13_dreaming) C++14
0 / 100
71 ms 11000 KB
#include"dreaming.h"
#include<bits/stdc++.h>
#define fr first
#define sc second
using namespace std;
vector<pair<int,int>>g[100005];
bool vis[100005];
int mx[100005],mx2[100005],id[100005],mm;
int dfs(int v,int p){
    vis[v]=1;
    int i=0,x;
    for(;i<g[v].size();i++)
        if(g[v][i].fr!=p){
            x=dfs(g[v][i].fr,v)+g[v][i].sc;
            if(x>mx2[v]){
                mx2[v]=x;
                id[v]=g[v][i].fr;
            }
        }
    return mx2[v];
}
void go(int v,int p,int val,int depth){
    mx[v]=max(val,depth);
    int m=0,i=0;
    for(;i<g[v].size();i++)
        if(g[v][i].fr!=p)
        if(g[v][i].fr!=id[v]){
            m=max(m,mx2[g[v][i].fr]+g[v][i].sc);
            go(g[v][i].fr,v,max(mx2[v],val)+g[v][i].sc,depth+g[v][i].sc);
        }
    if(id[v]!=-1)go(id[v],v,max(m,val)+g[v][i].sc,depth+g[v][i].sc);
}
void calc(int v,int p){
    mm=min(mm,max(mx2[v],mx[v]));
    for(auto to:g[v])if(to.fr!=p)calc(to.fr,v);
}
int travelTime(int n,int m,int l,int x[],int y[],int z[]){
    memset(id,-1,sizeof(id));
    for(int i=0;i<m;i++){
        g[x[i]].push_back({y[i],z[i]});
        g[y[i]].push_back({x[i],z[i]});
    }
    stack<int>st;
    g[n].push_back({n,0});
    for(int i=0;i<n;i++)if(!vis[i]){
        g[n][0].fr=i;
        dfs(n,n);
        go(n,n,0,0);
        mm=2e9;
        calc(n,n);
        st.push(mm);
    }
    int a=st.top();
    st.pop();
    while(!st.empty()){
        int b=st.top();
        st.pop();
        a=min(max(a,b+l),max(b,a+l));
    }
    return a;
}

Compilation message

dreaming.cpp: In function 'int dfs(int, int)':
dreaming.cpp:12:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(;i<g[v].size();i++)
      |          ~^~~~~~~~~~~~
dreaming.cpp: In function 'void go(int, int, int, int)':
dreaming.cpp:25:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(;i<g[v].size();i++)
      |          ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 11000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 11000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 11000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 6520 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 11000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 11000 KB Output isn't correct
2 Halted 0 ms 0 KB -