Submission #584036

# Submission time Handle Problem Language Result Execution time Memory
584036 2022-06-26T16:59:29 Z gangmtfk Dreaming (IOI13_dreaming) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
const int maxn=100002;
int n,m,l,ma,mark,cntcp,cp[maxn],dis[maxn][4],dia,ret;
vector<pii> a[maxn]; bool in[maxn][4];
void dfs(int u, int time)
{
    if(time==3) ret=min(ret,max(dis[u][2],dis[u][3]));
    in[u][time]=true;
    for(auto v:a[u])
    {
        if(in[v.fi][time]) continue;
        dis[v.fi][time]=dis[u][time]+v.se;
        if(dis[v.fi][time]>ma)
        {
            ma=dis[v.fi][time];
            mark=v.fi;
        }
        dfs(v.fi,time);
    }
}
int maxdis(int root)
{
    memset(dis,0,sizeof(dis));
    mark=0; ma=0; ret=1e9;
    dfs(root,1);
    int A=mark; mark=0; ma=0;
    dfs(A,2); dia=max(dia,ma);
    int B=mark; mark=0; ma=0;
    dfs(B,3);
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m >> l;
    for(int i=1; i<=m; i++)
    {
        int x,y,z; cin >> x >> y >> z;
        a[x].push_back({y,z});
        a[y].push_back({x,z});
    }
    for(int i=0; i<n; i++)
    {
        if(in[i][3]) continue;
        cp[++cntcp]=maxdis(i);
    }
    if(cntcp==1)
    {
        cout << dia;
        return 0;
    }
    sort(cp+1,cp+1+cntcp,greater<int>());
    if(cntcp==2) cout << max(dia,l+cp[1]+cp[2]);
    else cout << max(dia,max(2*l+cp[2]+cp[3],l+cp[1]+cp[2]));
    //for(int i=1; i<=cntcp; i++) cout << cp[i]<< " ";
    return 0;
}

Compilation message

/usr/bin/ld: /tmp/cc6GI8rQ.o: in function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cctCe89M.o:grader.c:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cctCe89M.o: in function `main':
grader.c:(.text.startup+0xd1): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status