Submission #438065

# Submission time Handle Problem Language Result Execution time Memory
438065 2021-06-27T13:36:56 Z adamjinwei Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
959 ms 69688 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define inf 1000000007
#define mod 1000000007
#define rnd() rand_num()
#define bigrnd() dis(rand_num)
//#pragma GCC optimize("Ofast","inline","-ffast-math")
//#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#define int long long
using namespace std;
unsigned sed=std::chrono::system_clock::now().time_since_epoch().count();
mt19937 rand_num(sed);
uniform_int_distribution<long long> dis(0,inf);
template <typename T> void read(T &x){
	x=0;char ch=getchar();int fh=1;
	while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
	while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x*=fh;
}
template <typename T> void write(T x) {
	if (x<0) x=-x,putchar('-');
	if (x>9) write(x/10);
	putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n;
int h[100005],e[2000005],w[2000005],ne[2000005],idx;
int dist[100005][2];
bool vis[100005];
void add(int a,int b,int c)
{
	e[idx]=b,w[idx]=c,ne[idx]=h[a],h[a]=idx++;
}
signed travel_plan(signed N,signed M,signed R[][2],signed L[],signed K,signed P[])
{
	n=N;
	memset(h,-1,sizeof(h));
	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]);
	}
	memset(dist,0x3f,sizeof(dist));
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
	for(int i=0;i<K;++i)
	{
		dist[P[i]][0]=dist[P[i]][1]=0;
		pq.push(make_pair(0,P[i]));
	}
	while(!pq.empty())
	{
		pair<int,int> p=pq.top();
		pq.pop();
		if(vis[p.second]) continue;
		vis[p.second]=1;
		if(dist[p.second][1]!=p.first) continue;
		for(int i=h[p.second];~i;i=ne[i])
		{
			int j=e[i];
			if(vis[j]) continue;
			if(dist[j][0]>p.first+w[i])
			{
				dist[j][1]=dist[j][0];
				dist[j][0]=p.first+w[i];
				pq.push(make_pair(dist[j][1],j));
			}
			else if(dist[j][1]>p.first+w[i])
			{
				dist[j][1]=p.first+w[i];
				pq.push(make_pair(dist[j][1],j));
			}
		}
	}
	return dist[0][1];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 6 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 8 ms 2764 KB Output is correct
5 Correct 8 ms 2764 KB Output is correct
6 Correct 10 ms 2660 KB Output is correct
7 Correct 7 ms 2764 KB Output is correct
8 Correct 2 ms 2740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 6 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 8 ms 2764 KB Output is correct
5 Correct 8 ms 2764 KB Output is correct
6 Correct 10 ms 2660 KB Output is correct
7 Correct 7 ms 2764 KB Output is correct
8 Correct 2 ms 2740 KB Output is correct
9 Correct 4 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 6 ms 3276 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 6 ms 2636 KB Output is correct
3 Correct 3 ms 2636 KB Output is correct
4 Correct 8 ms 2764 KB Output is correct
5 Correct 8 ms 2764 KB Output is correct
6 Correct 10 ms 2660 KB Output is correct
7 Correct 7 ms 2764 KB Output is correct
8 Correct 2 ms 2740 KB Output is correct
9 Correct 4 ms 3020 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 3 ms 2764 KB Output is correct
12 Correct 6 ms 3276 KB Output is correct
13 Correct 5 ms 3276 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 3 ms 2812 KB Output is correct
16 Correct 756 ms 65648 KB Output is correct
17 Correct 98 ms 16564 KB Output is correct
18 Correct 157 ms 17208 KB Output is correct
19 Correct 959 ms 69688 KB Output is correct
20 Correct 354 ms 61380 KB Output is correct
21 Correct 72 ms 8512 KB Output is correct
22 Correct 341 ms 55932 KB Output is correct