제출 #1290834

#제출 시각아이디문제언어결과실행 시간메모리
1290834blackscreen1악어의 지하 도시 (IOI11_crocodile)C++20
89 / 100
369 ms72800 KiB
#include "crocodile.h"
#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_multiset;
#define ll long long
#define ld long double
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define lloop(m, h) for (auto l = m; l != h; l += (m < h ? 1 : -1))
#define iloop_(m, h, g) for (auto i = m; i < h; i += g)
#define jloop_(m, h, g) for (auto j = m; j < h; j += g)
#define kloop_(m, h, g) for (auto k = m; k < h; k += g)
#define lloop_(m, h, g) for (auto l = m; l < h; l += g)
#define getchar_unlocked _getchar_nolock // comment before submission
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define pllll pair<pll, pll>
#define vll vector<ll>
#define qll queue<ll>
#define dll deque<ll>
#define pqll priority_queue<ll>
#define gll greater<ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	ll n = N, m = M;
	vector<pll> adj[n];
	iloop(0, m) {
		adj[R[i][0]].push_back({L[i], R[i][1]});
		adj[R[i][1]].push_back({L[i], R[i][0]});
	}
	ll d1[n], d2[n];
	iloop(0, n) {d1[i] = d2[i] = INF;}
	priority_queue<pll, vector<pll>, greater<pll>> pq;
	iloop(0, K) {
		d1[P[i]] = d2[P[i]] = 0;
		pq.push({0, P[i]});
	}
	while (pq.size()) {
		pll nd = pq.top();
		pq.pop();
		if (d2[nd.second] != nd.first) continue;
		for (auto it : adj[nd.second]) {
			if (d1[it.second] == INF) d1[it.second] = nd.first + it.first;
			else if (d2[it.second] > nd.first + it.first) {
				d2[it.second] = min(d2[it.second], max(d1[it.second], nd.first + it.first));
				d1[it.second] = min(d1[it.second], nd.first + it.first);
				pq.push({d2[it.second], it.second});
			}
		}
	}
	return d2[0];
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...