Submission #1102616

# Submission time Handle Problem Language Result Execution time Memory
1102616 2024-10-18T12:42:53 Z asli_bg Crocodile's Underground City (IOI11_crocodile) C++11
Compilation error
0 ms 0 KB
#pragma GCC optimize("O3,unroll-loops")
 
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define FOR(i,a) for(int i=0;i<(a);i++)
#define FORE(i,a,b) for(int i=(a);i<(b);i++)
 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pii> vii;
 
#define cont(x) for(auto el:x) {cout<<el<<' ';} cout<<endl;
#define endl '\n'
#define contp(x) for(auto el:x) {cout<<el.fi<<'-'<<el.se<<' ';} cout<<endl;
#define pb push_back
 
#define sp <<' '<<
 
#define DEBUG(x) {cout<<(#x) sp x<<endl;}
 
const int MAXN=1e6+5;
const int INF=15;
 
int n,m,k;
vii adj[MAXN];
//her node için min 3 yolu tut, nereden geldiğiyle birlikte
multiset<pii> yol[MAXN];
bool vis[MAXN];
bool cikis[MAXN];
 
void bfs(){
    set<pii> s;
    FORE(i,1,n+1){
        if(cikis[i]){
            yol[i].insert({0,i});
            yol[i].insert({0,i});
            yol[i].insert({0,i});
            s.insert({0,i});
        }
        else{
            yol[i].insert({INF,INF});
            yol[i].insert({INF,INF});
            yol[i].insert({INF,INF});
        }
    }
 
    while(!s.empty()){
        auto el=*s.begin();
        s.erase(*s.begin());
 
        int dd=el.fi;
        int nd=el.se;
 
        vis[nd]=true;
 
        for(auto temp:adj[nd]){
            int kom=temp.fi;
            int cost=temp.se;

            DEBUG(kom);
            DEBUG(cikis[kom]);
 
            if(cikis[kom]) continue;
            s.erase({yol[kom].begin()->fi,kom});
            yol[kom].insert({dd+cost,nd});
            //her komsu node için bir tane min degerini sadece tut
            if(yol[kom].size()>3){
                //sonuncu elemanı sil
                yol[kom].erase(yol[kom].find(*yol[kom].rbegin()));
            }
 
            if(vis[kom]) continue;
            s.insert({yol[kom].begin()->fi,kom});
        }
    }

    FORE(i,1,n+1){
        cout<<"node" sp i<<endl;
        for(auto el:yol[i]){
            cout<<el.fi<<'-'<<el.se<<' ';
        }
        cout<<endl;
    }
    cout<<endl;
}
 
int cev;
 
void dfs(int nd,int ata,int dd){
    vis[nd]=true;
 
    auto it=yol[nd].begin();
    if(it->fi==0){
        cev=min(cev,dd);
        return;
    }

    if(it->se==ata){
        it++;
    }

    int mn=it->se;

    for(auto el:adj[nd]){
        int kom=el.fi;
        int cost=el.se;
        if(kom==ata or kom==mn) continue;
        if(!vis[kom]) dfs(kom,nd,dd+cost);
    }
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    cin>>n>>m>>k;
    FOR(i,m){
        int a,b,c;
        cin>>a>>b>>c;
        a++;b++;
        adj[a].pb({b,c});
        adj[b].pb({a,c});
    }

    FOR(i,k){
        int el;
        cin>>el;
        el++;
        cikis[el]=true;
    }

    bfs();
    cev=INF;

    FORE(i,1,n+1) vis[i]=false;
    dfs(1,0,0);

    cout<<cev<<endl;
}  

Compilation message

/usr/bin/ld: /tmp/ccSxa2Ro.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccpkp0Om.o:crocodile.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccSxa2Ro.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