답안 #985322

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985322 2024-05-17T15:13:13 Z doducanh 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
const int maxx=1e12+7;
const int maxn=1e5+7;
vector<ii>a[maxn];
bool dd[maxn];
int n,m,k;
struct Best
{
    int fi,se;
    bool operator <(const Best &b)const
    {
        return (fi<b.fi||(fi==b.fi&&se<b.se));
    }
};
Best f[maxn];
#define Data pair<Best,int>
main()
{
    freopen("crocodile.inp","r",stdin);
    freopen("crocodile.out","w",stdout);
    cin>>n>>m>>k;
    vector<int>exit_chamber(k);
    for(int i=1;i<=m;i++){
        int u,v,w;
        cin>>u>>v>>w;
        a[u].push_back({v,w});
        a[v].push_back({u,w});
    }
    for(int &e:exit_chamber){
        cin>>e;
        dd[e]=true;
    }
    priority_queue<Data,vector<Data>,greater<Data>>q;
    for(int i=0;i<n;i++){
        if(dd[i]){
            f[i]={0,0};
            q.push({f[i],i});
        }
        else f[i]={maxx,maxx};
    }
    while(q.size()){
        Best du=q.top().fi;
        int u=q.top().se;
//        cout<<du.fi<<" "<<du.se<<" "<<u<<"\n";
        q.pop();
        if((du.fi!=f[u].fi||du.se!=f[u].se))continue;
        for(ii p:a[u]){
            int v=p.fi;
            int w=p.se;
            int canh=w+du.se;
            Best tmp=f[v];
            if(tmp.fi>canh){
                tmp.se=tmp.fi;
                tmp.fi=canh;
            }
            else if(tmp.se>canh){
                tmp.se=canh;
            }
            if(tmp<f[v]){
                f[v]=tmp;
                q.push({tmp,v});
            }
        }
    }
    cout<<f[0].se;
    return 0;
}

Compilation message

crocodile.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   24 | main()
      | ^~~~
crocodile.cpp: In function 'int main()':
crocodile.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen("crocodile.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen("crocodile.out","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccBuXl51.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbeoknY.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccBuXl51.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status