Submission #123846

# Submission time Handle Problem Language Result Execution time Memory
123846 2019-07-02T07:50:34 Z baluteshih Crocodile's Underground City (IOI11_crocodile) C++14
89 / 100
2000 ms 80444 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define MP make_pair
#define F first
#define S second
#define pb push_back
#define MEM(i,j) memset(i,j,sizeof i)
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll INF=1e18;
vector<pll> G[100005];
pll dp[100005];
bitset<100005> vis;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	for(int i=0;i<N;++i)
		dp[i]=MP(INF,INF);
	for(int i=0;i<M;++i)
		G[R[i][0]].pb(MP(L[i],R[i][1])),G[R[i][1]].pb(MP(L[i],R[i][0]));
	for(int i=0;i<K;++i)
		dp[P[i]]=MP(0,0);
	for(int i=0;i<N;++i)
	{
		int mi=-1;
		for(int j=0;j<N;++j)
			if(!vis[j]&&(!~mi||dp[j].S<dp[mi].S))
				mi=j;
		vis[mi]=1;
		for(auto j:G[mi])
			if(!vis[j.S])
			{
				ll x=dp[mi].S+j.F;
				if(x<dp[j.S].F)
					dp[j.S].S=dp[j.S].F,dp[j.S].F=x;
				else if(x<dp[j.S].S)
					dp[j.S].S=x;
			}
	}
	return dp[0].S;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 7 ms 2808 KB Output is correct
5 Correct 7 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 7 ms 2808 KB Output is correct
8 Correct 7 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 7 ms 2808 KB Output is correct
5 Correct 7 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 7 ms 2808 KB Output is correct
8 Correct 7 ms 2808 KB Output is correct
9 Correct 6 ms 3064 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2808 KB Output is correct
12 Correct 8 ms 3320 KB Output is correct
13 Correct 8 ms 3576 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 7 ms 2808 KB Output is correct
5 Correct 7 ms 2808 KB Output is correct
6 Correct 5 ms 2808 KB Output is correct
7 Correct 7 ms 2808 KB Output is correct
8 Correct 7 ms 2808 KB Output is correct
9 Correct 6 ms 3064 KB Output is correct
10 Correct 4 ms 2680 KB Output is correct
11 Correct 5 ms 2808 KB Output is correct
12 Correct 8 ms 3320 KB Output is correct
13 Correct 8 ms 3576 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Execution timed out 2056 ms 80444 KB Time limit exceeded
17 Halted 0 ms 0 KB -