Submission #64836

# Submission time Handle Problem Language Result Execution time Memory
64836 2018-08-05T19:43:29 Z zetapi Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
1626 ms 59148 KB
#include<vector>
#include<queue>
 
std::vector<std::pair<int,int> > G[100000];
std::priority_queue<std::pair<int,int> > PQ;
std::pair<int,int> P;
int D[100000];
 
int travel_plan(int N,int M,int R[][2],int L[],int K,int X[])
{
    int i;
    for(i=0;i<N;i++)
	{
		G[i].clear();
		D[i]=-1;
	}
    for(i=0;i<M;i++)
	{
		G[R[i][0]].push_back(std::make_pair(R[i][1],L[i]));
		G[R[i][1]].push_back(std::make_pair(R[i][0],L[i]));
	}
	for(i=0;i<K;i++)
	{
        D[X[i]]=-2;
		PQ.push(std::make_pair(0,X[i]));
	}
    while(!PQ.empty())
	{
		P=PQ.top();
		PQ.pop();
		if(D[P.second]>=0)continue;
		if(D[P.second]==-1)
		{
			D[P.second]=-2;
			continue;
		}
		D[P.second]=-P.first;
        for(i=0;i<G[P.second].size();i++)PQ.push(std::make_pair(P.first-G[P.second][i].second,G[P.second][i].first));
	}
	return D[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(i=0;i<G[P.second].size();i++)PQ.push(std::make_pair(P.first-G[P.second][i].second,G[P.second][i].first));
                 ~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 7 ms 2680 KB Output is correct
3 Correct 4 ms 2736 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 5 ms 2912 KB Output is correct
6 Correct 6 ms 2912 KB Output is correct
7 Correct 6 ms 2972 KB Output is correct
8 Correct 6 ms 2972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 7 ms 2680 KB Output is correct
3 Correct 4 ms 2736 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 5 ms 2912 KB Output is correct
6 Correct 6 ms 2912 KB Output is correct
7 Correct 6 ms 2972 KB Output is correct
8 Correct 6 ms 2972 KB Output is correct
9 Correct 8 ms 3188 KB Output is correct
10 Correct 4 ms 3188 KB Output is correct
11 Correct 6 ms 3188 KB Output is correct
12 Correct 13 ms 3584 KB Output is correct
13 Correct 10 ms 3684 KB Output is correct
14 Correct 6 ms 3684 KB Output is correct
15 Correct 6 ms 3684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 7 ms 2680 KB Output is correct
3 Correct 4 ms 2736 KB Output is correct
4 Correct 4 ms 2912 KB Output is correct
5 Correct 5 ms 2912 KB Output is correct
6 Correct 6 ms 2912 KB Output is correct
7 Correct 6 ms 2972 KB Output is correct
8 Correct 6 ms 2972 KB Output is correct
9 Correct 8 ms 3188 KB Output is correct
10 Correct 4 ms 3188 KB Output is correct
11 Correct 6 ms 3188 KB Output is correct
12 Correct 13 ms 3584 KB Output is correct
13 Correct 10 ms 3684 KB Output is correct
14 Correct 6 ms 3684 KB Output is correct
15 Correct 6 ms 3684 KB Output is correct
16 Correct 1551 ms 56392 KB Output is correct
17 Correct 163 ms 56392 KB Output is correct
18 Correct 160 ms 56392 KB Output is correct
19 Correct 1626 ms 59148 KB Output is correct
20 Correct 1018 ms 59148 KB Output is correct
21 Correct 79 ms 59148 KB Output is correct
22 Correct 764 ms 59148 KB Output is correct