Submission #756604

# Submission time Handle Problem Language Result Execution time Memory
756604 2023-06-12T01:22:02 Z maomao90 Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
2 ms 2656 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

#define REP(i, j, k) for (int i = j; i < k; i++)
#define RREP(i, j, k) for (int i = j; i >= k; i--)

template <class T>
inline bool mnto(T &a, const T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T &a, const T b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int) x.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef tuple<int, int, int> iii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 9000000000000000005;
const int MAXN = 100005;

int n, m, k;
vii adj[MAXN];
ll mnd[MAXN], smnd[MAXN];
priority_queue<pll, vector<pll>, greater<pll>> pq;

bool relax(int u, ll x) {
	if (x < mnd[u]) {
		smnd[u] = mnd[u];
		mnd[u] = x;
		return smnd[u] != LINF;
	} else {
		return mnto(smnd[u], x);
	}
}

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
	n = N; m = M; k = K;
	REP (i, 0, m) {
		adj[R[i][0]].pb({R[i][1], L[i]});
		adj[R[i][1]].pb({R[i][0], L[i]});
	}
	REP (i, 0, n) {
		mnd[i] = smnd[i] = LINF;
	}
	REP (i, 0, k) {
		mnd[P[i]] = smnd[P[i]] = 0;
		pq.push({0, P[i]});
	}
	while (!pq.empty()) {
		auto [d, u] = pq.top(); pq.pop();
		for (auto [v, w] : adj[u]) {
			if (relax(v, d + w)) {
				pq.push({smnd[v], v});
			}
		}
	}
	assert(smnd[0] != LINF);
	return smnd[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Incorrect 2 ms 2644 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Incorrect 2 ms 2644 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2656 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Incorrect 2 ms 2644 KB Output isn't correct
4 Halted 0 ms 0 KB -