Submission #638229

# Submission time Handle Problem Language Result Execution time Memory
638229 2022-09-05T03:17:36 Z zxcvbnm Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
162 ms 262144 KB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
constexpr int nax = 1005;
constexpr ll INF = 1e15+5;

vector<pair<int, int>> adj[nax];
ll dp[nax];
bool esc[nax];

void dfs(int v, int p=-1) {
	if (esc[v]) {
		return;
	}
	
	priority_queue<ll, vector<ll>, greater<ll>> q;
	for(auto& u : adj[v]) {
		if (p == u.first) continue;
		dfs(u.first, v);
		q.push(dp[u.first]+u.second);
	}
	
	if (q.size() >= 2) {
		q.pop();
		dp[v] = min(dp[v], q.top());
	}
	//cout << v << ": " << dp[v] << "\n";
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	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]});
	}
	
	for(int i = 0; i <= N; i++) {
		dp[i] = INF;
	}
	
	for(int i = 0; i < K; i++) {
		dp[P[i]] = 0;
		esc[P[i]] = true;
	}
	
	dfs(0);
	
	return dp[0];
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 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 476 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 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 476 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Runtime error 162 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 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 476 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Runtime error 162 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -