답안 #729990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
729990 2023-04-25T02:43:24 Z hoainiem 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
464 ms 81080 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define nmax 100008
const long long inf = 1e18;
using namespace std;
typedef pair<long long, long long> pii;
pii operator+(pii x, long long y){
    return (y <= x.fi) ? make_pair(y, x.fi) : ((y < x.se) ? make_pair(x.fi, y) : x);
}
int n, m;
bool kt[nmax];
pii f[nmax];
vector<pii> l[nmax];
typedef pair<pii, int> ppiii;
struct cmp{
    bool operator()(ppiii x, ppiii y){
        return x.fi.se > y.fi.se;
    }
};
priority_queue<ppiii, vector<ppiii>, cmp> s;
bool check(pii x, pii y){
    return (x.se != y.se) ? (x.se > y.se) : (x.fi > y.fi);
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    n = N;
    m = M;
    fill(f, f + n + 1, make_pair(inf, inf));
    for (int i = 0; i < m; i++){
        int u = R[i][0], v = R[i][1], w = L[i];
        l[u].push_back({v, w});
        l[v].push_back({u, w});
    }
    for (int i = 0; i < K; i++){
        f[P[i]] = {0, 0};
        s.push({f[P[i]], P[i]});
    }
    while (!s.empty()){
        int u = s.top().se;
        pii val = s.top().fi;
        s.pop();
        if (f[u] != val)
            continue;
        if (!u)
            break;
        for (pii it : l[u]){
            ppiii v = {f[it.fi] + (val.se + it.se), it.fi};
            if (check(f[v.se], v.fi)){
                f[v.se] = v.fi;
                s.push(v);
            }
        }
    }
    return f[0].se;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3284 KB Output is correct
13 Correct 4 ms 3296 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2772 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 3 ms 3028 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 2 ms 2772 KB Output is correct
12 Correct 4 ms 3284 KB Output is correct
13 Correct 4 ms 3296 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2772 KB Output is correct
16 Correct 375 ms 70884 KB Output is correct
17 Correct 84 ms 17500 KB Output is correct
18 Correct 87 ms 18336 KB Output is correct
19 Correct 464 ms 81080 KB Output is correct
20 Correct 255 ms 55088 KB Output is correct
21 Correct 38 ms 9172 KB Output is correct
22 Correct 275 ms 50684 KB Output is correct