답안 #756600

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
756600 2023-06-12T01:15:16 Z maomao90 악어의 지하 도시 (IOI11_crocodile) C++17
89 / 100
540 ms 68836 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<ll> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef tuple<ll, ll, ll> iii;
typedef vector<iii> viii;

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

const ll INF = 1000000005;
const ll LINF = 1000000000000000005;
const ll MAXN = 1000005;

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

bool relax(ll 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();
		if (d != smnd[u]) {
			continue;
		}
		for (auto [v, w] : adj[u]) {
			if (relax(v, d + w)) {
				pq.push({smnd[v], v});
			}
		}
	}
	assert(smnd[0] != LINF);
	return smnd[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23724 KB Output is correct
3 Correct 13 ms 23804 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 13 ms 23892 KB Output is correct
6 Correct 12 ms 23804 KB Output is correct
7 Correct 13 ms 23888 KB Output is correct
8 Correct 13 ms 23892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23724 KB Output is correct
3 Correct 13 ms 23804 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 13 ms 23892 KB Output is correct
6 Correct 12 ms 23804 KB Output is correct
7 Correct 13 ms 23888 KB Output is correct
8 Correct 13 ms 23892 KB Output is correct
9 Correct 14 ms 24020 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 15 ms 24148 KB Output is correct
13 Correct 19 ms 24268 KB Output is correct
14 Correct 14 ms 23764 KB Output is correct
15 Correct 13 ms 23796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 23764 KB Output is correct
2 Correct 13 ms 23724 KB Output is correct
3 Correct 13 ms 23804 KB Output is correct
4 Correct 12 ms 23892 KB Output is correct
5 Correct 13 ms 23892 KB Output is correct
6 Correct 12 ms 23804 KB Output is correct
7 Correct 13 ms 23888 KB Output is correct
8 Correct 13 ms 23892 KB Output is correct
9 Correct 14 ms 24020 KB Output is correct
10 Correct 15 ms 23756 KB Output is correct
11 Correct 13 ms 23892 KB Output is correct
12 Correct 15 ms 24148 KB Output is correct
13 Correct 19 ms 24268 KB Output is correct
14 Correct 14 ms 23764 KB Output is correct
15 Correct 13 ms 23796 KB Output is correct
16 Correct 434 ms 63636 KB Output is correct
17 Correct 76 ms 32352 KB Output is correct
18 Correct 95 ms 33716 KB Output is correct
19 Correct 540 ms 68836 KB Output is correct
20 Correct 256 ms 57744 KB Output is correct
21 Correct 47 ms 27560 KB Output is correct
22 Incorrect 275 ms 53196 KB Output isn't correct
23 Halted 0 ms 0 KB -