답안 #98705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98705 2019-02-25T07:57:40 Z tduong0806 꿈 (IOI13_dreaming) C++14
컴파일 오류
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);
}
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

dreaming.cpp:51:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
/tmp/ccOfHmww.o: In function `main':
dreaming.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cctcTZzw.o:grader.c:(.text.startup+0x0): first defined here
/tmp/cctcTZzw.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status