Submission #18645

# Submission time Handle Problem Language Result Execution time Memory
18645 2016-02-13T09:40:40 Z ggoh Crocodile's Underground City (IOI11_crocodile) C++
89 / 100
595 ms 156388 KB
#include "crocodile.h"
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
int a,b,c;
long long D[100003][2];
struct A{
    int to,cost;
};
std::vector<A>G[100003];
struct B{
    int pos;long long min;
};
std::priority_queue<B>PQ;
bool operator<(B aa,B bb){return aa.min>bb.min;}
int travel_plan(int N,int M,int R[][2],int L[],int K,int P[])
{
    a=N;
    b=M;
    c=K;
    for(int i=0;i<b;i++)
    {
        G[R[i][0]].push_back({R[i][1],L[i]});
        G[R[i][1]].push_back({R[i][0],L[i]});
    }
    long long X=1e9;
    int u,l;
    for(int i=0;i<a;i++)D[i][0]=D[i][1]=X*X;
    for(int i=0;i<c;i++)
    {
        D[P[i]][0]=D[P[i]][1]=0;
        for(int j=0;j<G[P[i]].size();j++)
        {
            u=G[P[i]][j].to;l=G[P[i]][j].cost;
            if(D[u][0]>l)
            {
                D[u][1]=D[u][0];
                D[u][0]=l;
                if(D[u][1]!=X*X)PQ.push({u,D[u][1]});
            }
            else if(D[u][1]>l)
            {
                D[u][1]=l;
                PQ.push({u,D[u][1]});
            }
        }
    }
    while(!PQ.empty())
    {
        B o=PQ.top();PQ.pop();
        if(D[o.pos][1]!=o.min)continue;
        for(int i=0;i<G[o.pos].size();i++)
        {
            u=G[o.pos][i].to;l=G[o.pos][i].cost;
            if(D[u][0]>l+o.min)
            {
                D[u][1]=D[u][0];
                D[u][0]=l+o.min;
                if(D[u][1]!=X*X)PQ.push({u,D[u][1]});
            }
            else if(D[u][1]>l+o.min)
            {
                D[u][1]=l+o.min;
                PQ.push({u,D[u][1]});
            }
        }
    }
    return (int)D[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 122868 KB Output is correct
2 Correct 2 ms 122868 KB Output is correct
3 Correct 0 ms 122868 KB Output is correct
4 Correct 0 ms 122868 KB Output is correct
5 Correct 0 ms 122868 KB Output is correct
6 Correct 0 ms 122868 KB Output is correct
7 Correct 2 ms 122868 KB Output is correct
8 Correct 0 ms 122868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 123000 KB Output is correct
2 Correct 0 ms 122868 KB Output is correct
3 Correct 3 ms 122868 KB Output is correct
4 Correct 0 ms 123000 KB Output is correct
5 Correct 0 ms 123132 KB Output is correct
6 Correct 2 ms 122868 KB Output is correct
7 Correct 0 ms 122868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 544 ms 150996 KB Output is correct
2 Correct 94 ms 127488 KB Output is correct
3 Correct 126 ms 128676 KB Output is correct
4 Correct 595 ms 156388 KB Output is correct
5 Correct 355 ms 145756 KB Output is correct
6 Correct 46 ms 125112 KB Output is correct
7 Incorrect 306 ms 141216 KB Output isn't correct