Submission #897395

# Submission time Handle Problem Language Result Execution time Memory
897395 2024-01-03T03:29:52 Z Sir_Ahmed_Imran Dreaming (IOI13_dreaming) C++17
Compilation error
0 ms 0 KB
                              ///~~~LOTA~~~///
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
#define nl '\n'
#define ff first
#define ss second
#define ll long long 
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define N 100000
int ans;
int vis[N];
int dp1[N];
int dp2[N];
int dp3[N];
vector<pii> a[N];
void dfs(int v){
    vis[v]=1;
    for(auto& i:a[v]){
        if(vis[i.ff]) continue;
        dfs(i.ff);
        if(dp1[i.ff]+i.ss>dp1[v]){
            dp2[v]=dp1[v];
            dp1[v]=dp1[i.ff]+i.ss;
        }
        else 
            dp2[v]=max(dp2[v],dp1[i.ff]+i.ss);
    }
}
int dfs2(int v,int u){
    ans=max(ans,dp1[v]+dp2[v]);
    ans=max(ans,dp1[v]+dp3[v]);
    int o=max(dp1[v],dp3[v]);
    for(auto& i:a[v]){
        if(i.ff==u)
            continue;
        dp3[i.ff]=dp3[v]+i.ss;
        if(dp1[i.ff]+i.ss==dp1[v])
            dp3[i.ff]=max(dp3[i.ff],dp2[v]+i.ss);
        else dp3[i.ff]=max(dp3[i.ff],dp1[v]+i.ss);
        o=min(o,dfs2(i.ff,v));
    }
    return o;
}
int travelTime(int n,int m,int l,vector<int> p,vector<int> q,vector<int> t){
    for(int i=ans=0;i<m;i++){
        a[p[i]].append({q[i],t[i]});
        a[q[i]].append({p[i],t[i]});
    }
    vector<int> v;
    for(int i=0;i<n;i++){
        if(vis[i]) 
            continue;
        dfs(i);
        v.append(dfs2(i,-1));
    }
    sort(all(v));
    v.back()-=l;
    sort(all(v));
    reverse(all(v));
    if(v.size()>1)
        ans=max(ans,v[0]+v[1]+2*l);
    return ans;
}

Compilation message

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