답안 #110948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110948 2019-05-13T10:00:37 Z The_Wolfpack 꿈 (IOI13_dreaming) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define pii pair<int,int>
#define x first
#define y second 
using namespace std;

const int NMAX=1e5+7;

int vis[NMAX]; 
pii mx1[NMAX],mx2[NMAX]; 
vector<pii> g[NMAX];  

int ans=0; 
int naj=1e9+7;
void dfs(int son, int par)
{
    vis[son]=1;
    for(pii nxt:g[son])
    {
        if(nxt.x==par) continue; 
        dfs(nxt.x,son); 
        pii tmp={mx1[nxt.x].x+nxt.y,nxt.x};  
        if(tmp>mx1[son]) swap(mx1[son],tmp); 
        if(tmp>mx2[son]) swap(mx2[son],tmp);   
    }
    ans=max(ans,mx1[son].x+mx2[son].x); 
}

void nadji(int son, int par, int dub)
{  
    naj=min(naj,max(dub,mx1[son].x)); 
    for(pii nxt:g[son]) 
    {
        if(nxt.x==par) continue;
        int dub2=nxt.y+max(d,(nxt.x==mx1[son].y)?mx2[son].x:mx1[son].x);   
        nadji(nxt.x,son,dub2); 
    }
}

int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
    for(int i=0;i<M;i++)
    {
        g[A[i]].push_back({B[i],T[i]}); 
        g[B[i]].push_back({A[i],T[i]});    
    }
    vector<int> rad; 
    for(int i=0;i<N;i++)
    {
        if(!vis[i]) 
        {
            dfs(i,-1); 
            naj=1e9+7; 
            nadji(i,-1,0); 
            rad.push_back(naj); 
        }
    }
    sort(rad.rbegin(),rad.rend());  
    if(rad.size()>=2) ans=max(ans,rad[0]+rad[1]+L); 
    if(rad.size()>=3) ans=max(ans,rad[1]+rad[2]+2*L); 
    return ans; 
}

Compilation message

dreaming.cpp: In function 'void nadji(int, int, int)':
dreaming.cpp:35:28: error: 'd' was not declared in this scope
         int dub2=nxt.y+max(d,(nxt.x==mx1[son].y)?mx2[son].x:mx1[son].x);   
                            ^