Submission #743925

# Submission time Handle Problem Language Result Execution time Memory
743925 2023-05-18T06:14:24 Z josanneo22 Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
8 ms 7508 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 = (int)(1e5+20);
vector<vector<pii>> adj(maxn);
vector<pii> ans(maxn,mp(1e9,1e9));
vector<int> win(maxn, 0);
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;
	}
	priority_queue<pii,vector<pii>,greater<pii>> pq;
	pq.push(mp(0, 0));//first is weight, second is index
	while (pq.size()) {
		pii u = pq.top(); pq.pop();
		if (ans[u.se].fi < u.fi) {
			ans[u.se].se = min(ans[u.se].se, ans[u.se].fi);
			ans[u.se].fi = u.fi;
			for (auto& v : adj[u.second]) {
				pq.push(mp(u.fi+v.fi, v.se));
			}
		}
		if (ans[u.se].se < u.fi) {
			ans[u.se].se = u.fi;
			for (auto& v : adj[u.second]) {
				pq.push(mp(u.fi + v.fi, v.se));
			}
		}
	}
	vector<int> res;
	for (int i = 0; i < n; i++) {
		if (win[i]) {
			if (ans[i].first != 1e9) res.push_back(ans[i].first);
			if (ans[i].second != 1e9) res.push_back(ans[i].second);
		}
	}
	sort(res.begin(), res.end());
	int tot = (res.size() + 1) / 2;
	return res[tot];
} 
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 7508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 7508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 7508 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -