Submission #133704

# Submission time Handle Problem Language Result Execution time Memory
133704 2019-07-21T08:48:23 Z Boxworld Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
729 ms 61348 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> Pa;
const int maxN=100100;
struct edge{int v,d,nxt;}a[20*maxN];
int vis[maxN],head[maxN];
int cnt=0;
priority_queue<Pa,vector<Pa>,greater<Pa> > Q;
void add(int u,int v,int d){
	a[cnt].v=v;
	a[cnt].d=d;
	a[cnt].nxt=head[u];
	head[u]=cnt++;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	for (int i=0;i<N;i++){vis[i]=0;head[i]=-1;}
	for (int i=0;i<M;i++){
		add(R[i][0],R[i][1],L[i]);
		add(R[i][1],R[i][0],L[i]);
	}
	for (int i=0;i<K;i++){
		Q.push(make_pair(0,P[i]));
		vis[P[i]]=1;
	}
	while(!Q.empty()){
		int dis=Q.top().first,u=Q.top().second;Q.pop();
		if (++vis[u]!=2)continue;
		if (u==0)return dis;
		for (int i=head[u];i!=-1;i=a[i].nxt)Q.push(make_pair(dis+a[i].d,a[i].v));
	}
}


 

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 4 ms 760 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 8 ms 1272 KB Output is correct
13 Correct 5 ms 760 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 4 ms 760 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 8 ms 1272 KB Output is correct
13 Correct 5 ms 760 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 412 KB Output is correct
16 Correct 729 ms 61348 KB Output is correct
17 Correct 99 ms 11476 KB Output is correct
18 Correct 104 ms 12000 KB Output is correct
19 Correct 639 ms 53520 KB Output is correct
20 Correct 323 ms 42244 KB Output is correct
21 Correct 50 ms 5188 KB Output is correct
22 Correct 680 ms 39592 KB Output is correct