Submission #211317

# Submission time Handle Problem Language Result Execution time Memory
211317 2020-03-20T04:15:33 Z socho Crocodile's Underground City (IOI11_crocodile) C++14
46 / 100
172 ms 262148 KB
#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
// #define int long long

int n, m;
const int MXN = 1005;
vector<pair<int, int> > adj[MXN];
bool ter[MXN];
int dist[MXN];
int via[MXN];

int best(int node, int last) {
	if (ter[node]) return 0;
	vector<int> opts;
	for (int i=0; i<adj[node].size(); i++) {
		int f = adj[node][i].first, s = adj[node][i].second;
		if (f == last) continue;
		opts.push_back(s + best(f, node));
	}
	sort(opts.begin(), opts.end());
	return opts[1];
}

// #include "crocodile.h"

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
	n = N;
	m = M;
	for (int i=0; i<m; i++) {
		int a = R[i][0], b = R[i][1], w = L[i];
		adj[a].push_back(make_pair(b, w));
		adj[b].push_back(make_pair(a, w));
	}
	int k = K;
	for (int i=0; i<k; i++) {
		int x = P[i];
		ter[x] = true;
	}
	
	return best(0, -1);
}


Compilation message

crocodile.cpp: In function 'int best(int, int)':
crocodile.cpp:16:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<adj[node].size(); i++) {
                ~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 512 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 512 KB Output is correct
9 Runtime error 172 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Halted 0 ms 0 KB -