답안 #876762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
876762 2023-11-22T09:36:52 Z deadeye0 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
423 ms 75360 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define si second
#define ar array
#define pb push_back
typedef pair<ll,ll> pi;
typedef tuple<int,int,int> ti;  
typedef vector<int> vi;
template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
void debug_out() {cerr<<endl;}
template <typename Head, typename... Tail>
void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
const int MAXN = 100010;
const ll INF = 2e9;
int n, m;
int vis[MAXN];
ll d1[MAXN], d2[MAXN];
vector<vector<pi>> g;
priority_queue<pi, vector<pi>, greater<pi>> pq;
 
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) 
{
    n = N, m = M;
    g.resize(n);
    for (int i = 0; i < n; ++i) {
        d1[i] = d2[i] = INF;
    }
    for (int i = 0; i < m; ++i) {
        int u = R[i][0], v = R[i][1];
        g[u].pb({v, L[i]});
        g[v].pb({u, L[i]});
    }
    for (int i = 0; i < K; ++i)  {
        d1[P[i]] = 0;
        d2[P[i]] = 0;
        pq.push({0, P[i]});
    }   
    while (pq.size()) {
        auto [d, x] = pq.top(); pq.pop();
        if (vis[x]) continue;
        vis[x] = 1;
        for (auto i: g[x]) {
            ll val = d + i.si;
            if (val < d2[i.fi]) {
                d2[i.fi] = val;
                if (d2[i.fi] < d1[i.fi]) swap(d2[i.fi], d1[i.fi]);
                if (d2[i.fi] < INF) pq.push({d2[i.fi], i.fi});
            }
        }
    }
    return d2[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5060 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4696 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5060 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 323 ms 67620 KB Output is correct
17 Correct 52 ms 16720 KB Output is correct
18 Correct 69 ms 19024 KB Output is correct
19 Correct 423 ms 75360 KB Output is correct
20 Correct 218 ms 55476 KB Output is correct
21 Correct 27 ms 11612 KB Output is correct
22 Correct 237 ms 51904 KB Output is correct