답안 #453718

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
453718 2021-08-04T16:01:23 Z tht2005 꿈 (IOI13_dreaming) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define FORE(i,a) for(auto&i:a)
#define rep(i,a,b,z) for(int i=(a),_b=(b),_z=(z);i<=_b;i+=_z)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
 
#define fs first
#define sc second
typedef pair<int,int> ii;
const int nmax=100010;
 
int f[nmax],f2[nmax],g[nmax],vst[nmax];
vector<ii>adj[nmax];
 
void dfs(int u, int p=-1)
{
    vst[u]=*vst;
    f[u]=f2[u]=0;
    FORE(x,adj[u]){
        if(x.sc==p)continue;
        dfs(x.sc,u);
        if(f[u]<f[x.sc]+x.fs){
            f2[u]=f[u];
            f[u]=f[x.sc]+x.fs;
        }
        else if(f2[u]<f[x.sc]+x.fs)
            f2[u]=f[x.sc]+x.fs;
    }
}
 
void dfs2(int u, int p=-1)
{
    FORE(x,adj[u]){
        if(x.sc==p)continue;
        if(f[u]==f[x.sc]+x.fs)g[x.sc]=max(g[u],f2[u])+x.fs;
        else g[x.sc]=max(g[u],f[u])+x.fs;
        dfs2(x.sc,u);
    }
}
 
int calc(int n, int l, const vector<int>& a)
{
    int ans=0;
    int pos=max_element(a.begin()+1,a.end())-a.begin();
    FOR(i,1,n)if(i!=pos)ans=max(ans,a[i]+a[pos]+l);
    return ans;
}
 
int travelTime(int N,int M,int L,int A[],int B[],int T[])
{
    FOR(i,0,M-1){
        ++A[i],++B[i];
        adj[A[i]].push_back({T[i],B[i]});
        adj[B[i]].push_back({T[i],A[i]});
    }
    FOR(i,1,N)if(!vst[i])++*vst,dfs(i),dfs2(i);
    FOR(i,1,N)f[i]=max(f[i],g[i]);
    vector<int>a(*vst+1,0x3f3f3f3f);
    FOR(i,1,N)a[vst[i]]=min(a[vst[i]],f[i]);
    f[0]=calc(*vst,L,a);
    return *max_element(f,f+1+N);
}

Compilation message

/usr/bin/ld: /tmp/ccCqiMfE.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status