Submission #743894

# Submission time Handle Problem Language Result Execution time Memory
743894 2023-05-18T05:53:56 Z josanneo22 Crocodile's Underground City (IOI11_crocodile) C++17
46 / 100
162 ms 262144 KB
#include <bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include<algorithm>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second  

#include "crocodile.h"
const int maxn = 1006;
vector<vector<pii>> adj(maxn);
vector<pii> ans(maxn);
vector<int> win(maxn, 0);
void get(int u,int from) {
	if (win[u]) {
		ans[u].fi = 0; ans[u].se = 0;
		return;
	}
	vector<int> res;
	for (auto& v : adj[u]) {
		if (v.se == from) continue;
		get(v.se,u);
		res.push_back(ans[v.se].se+v.fi);
	} 
	sort(res.begin(), res.end());
	ans[u].fi = res[0];
	if (res.size() == 1) {
		ans[u].se = res[0];
	}
	else {
		ans[u].se = res[1];
	}
}
int travel_plan(int n, int m, int r[][2], int w[], int k, int p[])
{
	for (int i = 0; i < m; i++) {
		adj[r[i][0]].push_back(mp(w[i], r[i][1]));
		adj[r[i][1]].push_back(mp(w[i], r[i][0]));
	}
	for (int i = 0; i < k; i++) {
		win[p[i]] = 1;
	}
	get(0,-1);
	return ans[0].se;
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 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 480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 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 480 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 344 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 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 480 KB Output is correct
9 Runtime error 162 ms 262144 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -