Submission #98707

# Submission time Handle Problem Language Result Execution time Memory
98707 2019-02-25T07:59:01 Z tduong0806 Dreaming (IOI13_dreaming) C++11
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define int long long
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
#define read2(a,b) read(a),read(b)
#define read3(a,b,c) read(a),read(b),read(c)
const int N=100010;
int n,m,l,a[N],dd[N],tr[N],in[N],out[N];
vector<pii> ke[N];
vector<int> sv;
priority_queue<int> heap;
void In(int u)
{
    //cout<<u;
    sv.pb(u);
    dd[u]=1;
    forv(v,ke[u]) if(v.fi!=tr[u])
    {
        tr[v.fi]=u;
        In(v.fi);
        in[u]=max(in[u],in[v.fi]+v.se);
    }
}
void Out(int u)
{
    vector<pii> e;
    forv(v,ke[u]) if(v.fi!=tr[u])
    {
        out[v.fi]=max(out[v.fi],out[u]+v.se);
        e.pb({in[v.fi]+v.se,v.fi});
    }
    sort(all(e),greater<pii>());
    if(e.size()>1) forv(v,ke[u]) if(v.fi!=tr[u])
    {
        if(v.fi==e[0].se) out[v.fi]=max(out[v.fi],e[1].fi+v.se);
        else out[v.fi]=max(out[v.fi],e[0].fi+v.se);
    }
    forv(v,ke[u]) if(v.fi!=tr[u]) Out(v.fi);
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("DREAMING.inp","r",stdin);
    //freopen("DREAMING.out","w",stdout);
    cin>>n>>m>>l;
    forinc(i,1,m)
    {
        int u,v,c;
        cin>>u>>v>>c;
        ++u,++v;
        //cout<<u<<" "<<v<<" "<<c<<endl;
        ke[u].pb({v,c});
        ke[v].pb({u,c});
    }
    forinc(i,1,n) if(!dd[i])
    {
        In(i);Out(i);
        int ma=1e17;
        forv(x,sv)
        {
            //cout<<x<<" "<<in[x]<<" "<<out[x]<<endl;
            ma=min(ma,max(in[x],out[x]));
        }
        cout<<endl;
        sv.clear();
        heap.push(ma);
    }
    int kq=0;
    forinc(i,1,n)
    {
        //cout<<in[i]<<" "<<out[i]<<endl;
        kq=max(kq,in[i]+out[i]);
    }
    while(heap.size()>1)
    {
        int u=heap.top();heap.pop();
        int v=heap.top();heap.pop();
        kq=max(kq,u+v+l);
        heap.push(max(u,v)+l);
    }
    cout<<kq;
}

Compilation message

/tmp/ccgwWaOY.o: In function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc7AM7RM.o:grader.c:(.text.startup+0x0): first defined here
/tmp/cc7AM7RM.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status