Submission #466720

# Submission time Handle Problem Language Result Execution time Memory
466720 2021-08-20T13:55:50 Z FEDIKUS Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
240 ms 262148 KB
#include "crocodile.h"

#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second

using namespace std;

typedef pair<int,int> pii;

const int maxn=1e5+10;

vector<pii> g[maxn];
pii cene[maxn];

int uradi(pii &a,int b){
    if(b<a.xx){
        a.yy=a.xx;
        a.xx=b;
    }else if(b<a.yy){
        a.yy=b;
    }
}

int kurc(int k,int* p){
    priority_queue<pii,vector<pii>,greater<pii> > pq;
    for(int i=0;i<maxn;i++) cene[i]={INT_MAX,INT_MAX};
    for(int i=0;i<k;i++){
        pq.push(mp(0,p[i]));
        cene[p[i]]={0,0};
    }
    while(!pq.empty()){
        pii vrh=pq.top();
        pq.pop();
        if(vrh.xx!=cene[vrh.yy].yy) continue;
        if(vrh.yy==0) return vrh.xx;
        for(pii i:g[vrh.yy]){
            int sc=cene[i.xx].yy;
            uradi(cene[i.xx],vrh.xx+i.yy);
            if(sc>cene[i.xx].yy){
                pq.push(mp(cene[i.xx].yy,i.xx));
            }
        }
    }
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
    for(int i=0;i<m;i++){
        g[r[i][0]].pb(mp(r[i][1],l[i]));
        g[r[i][1]].pb(mp(r[i][0],l[i]));
    }
    return kurc(k,p);
}

Compilation message

crocodile.cpp: In function 'int uradi(pii&, int)':
crocodile.cpp:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
crocodile.cpp: In function 'int kurc(int, int*)':
crocodile.cpp:28:51: warning: control reaches end of non-void function [-Wreturn-type]
   28 |     priority_queue<pii,vector<pii>,greater<pii> > pq;
      |                                                   ^~
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 240 ms 262148 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -