Submission #582600

# Submission time Handle Problem Language Result Execution time Memory
582600 2022-06-24T07:22:46 Z 1ne Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
2 ms 468 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	vector<vector<pair<int,int>>>adj(N);
	for (int i = 0;i<M;++i){
		adj[R[i][0]].push_back({R[i][1],L[i]});
		adj[R[i][1]].push_back({R[i][0],L[i]});
	}
	vector<bool>visited(N,false);
	vector<vector<long long>>dp(N,vector<long long>(2,1e9));
	for (int i = 0;i<K;++i){dp[P[i]][0] = 0;dp[P[i]][1] = 0;visited[P[i]] = true;}
	function<long long(int)>dfs = [&](int u){
		if (visited[u])return dp[u][1];
		visited[u] = true;
		for (auto x:adj[u]){
			long long temp = dfs(x.first) + x.second;
			if (temp < dp[u][0]){
				dp[u][1] = dp[u][0];
				dp[u][0] = temp;
			}
			else if (temp < dp[u][1]){
				dp[u][1] = temp;
			}
		}
		return dp[u][1];
	};
	long long ans = dfs(0);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Incorrect 1 ms 340 KB Output isn't correct
11 Halted 0 ms 0 KB -