Submission #115518

# Submission time Handle Problem Language Result Execution time Memory
115518 2019-06-08T03:27:31 Z arnold518 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1000;
const ll INF = 98765432198765;

vector<pii> adj[MAXN+10];
pll dist[MAXN+10];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int i, j;
    for(i=0; i<M; i++)
    {
        int u=R[i][0], v=R[i][1], w=L[i];
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }

    queue<int> Q;

    for(i=0; i<N; i++) dist[i]={INF, INF};
    for(i=0; i<K; i++) dist[P[i]]={0, 0}, Q.push(P[i]);

    while(!Q.empty())
    {
        int now=Q.front();
        Q.pop();

        for(pii nxt : adj[now])
        {
            if(dist[now].second+nxt.second<dist[nxt.first].second)
            {
                if(dist[now].second+nxt.second<dist[nxt.first].first) dist[nxt.first].second=dist[nxt.first].first, dist[nxt.first].first=dist[now].second+nxt.second;
                else dist[nxt.first].second=dist[now].second+nxt.second;
                Q.push(nxt.first);
            }
        }
    }

    return dist[0].second;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:17:12: warning: unused variable 'j' [-Wunused-variable]
     int i, j;
            ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -