Submission #153104

# Submission time Handle Problem Language Result Execution time Memory
153104 2019-09-12T11:54:37 Z mhy908 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
2000 ms 2680 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define inf 987654321987654321
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n, m, k;
vector<pair<int, LL> > link[100010];
LL dijk[100010][3];
bool ch[100010];
priority_queue<pair<LL, int> >pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    n=N;
    m=M;
    k=K;
    for(int i=0; i<m; i++){
        link[R[i][0]].pb(make_pair(R[i][1], (LL)L[i]));
        link[R[i][1]].pb(make_pair(R[i][0], (LL)L[i]));
    }
    for(int i=1; i<=n; i++)dijk[i][1]=dijk[i][2]=inf;
    for(int i=0; i<k; i++)dijk[P[i]+1][1]=dijk[P[i]+1][2]=0, pq.push(make_pair(0, +P[i]+1));
    while(!pq.empty()){
        int here=pq.top().S;
        LL c=-pq.top().F;
        if(ch[here])continue;
        ch[here]=true;
        for(int i=0; i<link[here].size(); i++){
            int next=link[here][i].F;
            LL cost=link[here][i].S;
            if(ch[next])continue;
            if(dijk[next][1]>c+cost){
                dijk[next][2]=dijk[next][1];
                dijk[next][1]=c+cost;
                pq.push(make_pair(-dijk[next][2], next));
            }
            else if(dijk[next][2]>c+cost){
                dijk[next][2]=c+cost;
                pq.push(make_pair(-dijk[next][2], next));
            }
        }
    }
    return (int)dijk[1][2];
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0; i<link[here].size(); i++){
                      ~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 2680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 2680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 2680 KB Time limit exceeded
2 Halted 0 ms 0 KB -