Submission #229798

# Submission time Handle Problem Language Result Execution time Memory
229798 2020-05-06T14:20:19 Z quocnguyen1012 Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
694 ms 74488 KB
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define a first
#define b second
#define pb push_back
#include <crocodile.h>
llo ma=1000000001;
int travel_plan(int n,int m,int r[][2],int l[],int k,int p[]){
	llo vis[n];
	for(llo i=0;i<n;i++){
		vis[i]=0;
	}
	for(llo i=0;i<k;i++){
		vis[p[i]]=1;
	}
	vector<pair<llo,llo>> adj[n];
	for(llo i=0;i<m;i++){
		adj[r[i][0]].pb({r[i][1],(llo)l[i]});
		adj[r[i][1]].pb({r[i][0],(llo)l[i]});
	}
	llo dist[n];
	llo dist2[n];
	for(llo i=0;i<n;i++){
		dist[i]=ma;
		dist2[i]=ma;
	}
	priority_queue<pair<llo,llo>> ac;
	for(llo i=0;i<n;i++){
		if(vis[i]==1){
			dist[i]=0;
			dist2[i]=0;
			ac.push({0,i});
		}	
	}
	llo vis2[n];
	for(llo i=0;i<n;i++){
		vis2[i]=0;
	}
	while(ac.size()){
		pair<llo,llo> no=ac.top();
		ac.pop();
		no.a=-no.a;
		if(no.a>dist2[no.b]){
			continue;
		}
		for(auto j:adj[no.b]){
			llo co=dist2[no.b]+j.b;
			if(dist[j.a]>=co){
				llo acc=dist2[j.a];
				dist2[j.a]=dist[j.a];
				dist[j.a]=co;
				if(dist2[j.a]<acc and dist2[j.a]!=ma){
					ac.push({-dist2[j.a],j.a});
				}
			}
			else if(dist2[j.a]>co){
				dist2[j.a]=co;
				ac.push({-dist2[j.a],j.a});
			}
		}
	}
	return dist2[0];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:38:6: warning: variable 'vis2' set but not used [-Wunused-but-set-variable]
  llo vis2[n];
      ^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 1024 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Correct 7 ms 640 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 512 KB Output is correct
12 Correct 9 ms 896 KB Output is correct
13 Correct 8 ms 1024 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 546 ms 66048 KB Output is correct
17 Correct 96 ms 15992 KB Output is correct
18 Correct 121 ms 18296 KB Output is correct
19 Correct 694 ms 74488 KB Output is correct
20 Correct 358 ms 52216 KB Output is correct
21 Correct 49 ms 7416 KB Output is correct
22 Correct 382 ms 48888 KB Output is correct