#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
inline void read() {}
template <class S>
inline void read(S &arg) {
cin >> arg;
}
template <class S>
inline void readA(S Lptr, S Rptr) {
while (Lptr != Rptr) {
read(*Lptr);
Lptr++;
}
}
template <class S, class... T>
inline void read(S &arg, T &... rest) {
read(arg);
read(rest...);
}
inline void write() {}
template <class S>
inline void write(S arg) {
cout << arg;
}
template <class S>
inline void writeA(S Lptr, S Rptr, char C_ = ' ') {
if (Lptr != Rptr) {
write(*Lptr);
Lptr++;
}
while (Lptr != Rptr) {
write(C_);
write(*Lptr);
Lptr++;
}
}
template <class S, class... T>
inline void write(S arg, T... rest) {
write(arg);
write(' ');
write(rest...);
}
#define rep(i, j, k) for (int i = j; i < (int)k; i++)
#define pb push_back
#define mt make_tuple
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
template <class T, class S>
inline bool smin(T &a, S b) {
return (T)b < a ? a = b, 1 : 0;
}
template <class T, class S>
inline bool smax(T &a, S b) {
return a < (T)b ? a = b, 1 : 0;
}
constexpr int MOD = 1e9 + 7;
constexpr int N = 1e6 + 10;
template <typename T>
inline T mod(T &v) {
return v = (v % MOD + MOD) % MOD;
}
template <typename S, typename T>
inline S add(S &l, T r) {
return mod(l += r);
}
ll po(ll v, ll u) {
return u ? po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD : 1;
}
pll dist[N];
set<pair<pll, int>> st;
vi adj[N];
int travel_plan(int n, int m, int R[][2], int L[], int k, int P[]) {
rep(i, 0, m) {
adj[R[i][0]].pb(i);
adj[R[i][1]].pb(i);
}
memset(dist, 63, sizeof(dist));
rep(i, 0, k) {
dist[P[i]] = {0, 0};
st.insert({dist[P[i]], P[i]});
}
while (st.size()) {
int v = st.begin()->second;
st.erase(st.begin());
for (auto e : adj[v]) {
ll exp = dist[v].first + L[e];
int u = R[e][0] ^ R[e][1] ^ v;
pll nd = dist[u];
if (exp <= nd.second) {
nd.first = nd.second;
nd.second = exp;
} else if (exp < nd.first)
nd.first = exp;
if (nd != dist[u]) {
st.erase({dist[u], u});
dist[u] = nd;
st.insert({dist[u], u});
}
}
}
return dist[0].first;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
39544 KB |
Output is correct |
2 |
Correct |
38 ms |
39416 KB |
Output is correct |
3 |
Correct |
39 ms |
39592 KB |
Output is correct |
4 |
Correct |
39 ms |
39672 KB |
Output is correct |
5 |
Correct |
38 ms |
39576 KB |
Output is correct |
6 |
Correct |
38 ms |
39544 KB |
Output is correct |
7 |
Correct |
42 ms |
39544 KB |
Output is correct |
8 |
Correct |
40 ms |
39544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
39544 KB |
Output is correct |
2 |
Correct |
38 ms |
39416 KB |
Output is correct |
3 |
Correct |
39 ms |
39592 KB |
Output is correct |
4 |
Correct |
39 ms |
39672 KB |
Output is correct |
5 |
Correct |
38 ms |
39576 KB |
Output is correct |
6 |
Correct |
38 ms |
39544 KB |
Output is correct |
7 |
Correct |
42 ms |
39544 KB |
Output is correct |
8 |
Correct |
40 ms |
39544 KB |
Output is correct |
9 |
Correct |
39 ms |
39780 KB |
Output is correct |
10 |
Correct |
37 ms |
39476 KB |
Output is correct |
11 |
Correct |
38 ms |
39544 KB |
Output is correct |
12 |
Correct |
38 ms |
39800 KB |
Output is correct |
13 |
Correct |
37 ms |
39800 KB |
Output is correct |
14 |
Correct |
35 ms |
39544 KB |
Output is correct |
15 |
Correct |
35 ms |
39544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
37 ms |
39544 KB |
Output is correct |
2 |
Correct |
38 ms |
39416 KB |
Output is correct |
3 |
Correct |
39 ms |
39592 KB |
Output is correct |
4 |
Correct |
39 ms |
39672 KB |
Output is correct |
5 |
Correct |
38 ms |
39576 KB |
Output is correct |
6 |
Correct |
38 ms |
39544 KB |
Output is correct |
7 |
Correct |
42 ms |
39544 KB |
Output is correct |
8 |
Correct |
40 ms |
39544 KB |
Output is correct |
9 |
Correct |
39 ms |
39780 KB |
Output is correct |
10 |
Correct |
37 ms |
39476 KB |
Output is correct |
11 |
Correct |
38 ms |
39544 KB |
Output is correct |
12 |
Correct |
38 ms |
39800 KB |
Output is correct |
13 |
Correct |
37 ms |
39800 KB |
Output is correct |
14 |
Correct |
35 ms |
39544 KB |
Output is correct |
15 |
Correct |
35 ms |
39544 KB |
Output is correct |
16 |
Correct |
842 ms |
81456 KB |
Output is correct |
17 |
Correct |
127 ms |
48248 KB |
Output is correct |
18 |
Correct |
228 ms |
49648 KB |
Output is correct |
19 |
Correct |
1414 ms |
86500 KB |
Output is correct |
20 |
Correct |
334 ms |
75720 KB |
Output is correct |
21 |
Correct |
152 ms |
43384 KB |
Output is correct |
22 |
Correct |
374 ms |
73696 KB |
Output is correct |