답안 #669080

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
669080 2022-12-05T14:09:12 Z kirakaminski968 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
554 ms 63008 KB
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset = 
            tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define ld long double
#define ar array
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int, int>
#define pb push_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define endl "\n"
const int MOD = 1e9+7;
const int inf = 1e9;
const ll linf = 1e18;
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
int sol(int n, int m, int (*edges)[2], int* l, int k, int *entry) {
    vector<array<int, 2>> g[n];
    for (int i = 0; i < m; i++) {
        int a = edges[i][0], b = edges[i][1], c = l[i];
        g[a].pb({b, c});
        g[b].pb({a, c});
    }
    priority_queue<pii, vector<pii>, greater<pii>> q;
    vii dis(n);
    vi vis(n, 0);
    for (int i = 0; i < k; i++) {
        int temp = entry[i];
        q.push({0, temp});
        dis[temp].pb(0); dis[temp].pb(0);
        vis[temp]++;
    }
    while (!q.empty()) {
        int src = q.top().s, dist = q.top().f; q.pop();
        if (vis[src] >= 2) continue;
        vis[src]++;
        if (vis[src] != 2) continue;
        if (src == 0) {
            return dist;
        }
        for (auto child : g[src]) {
            int ch = child[0], wt = child[1];
            if (dis[ch].size() == 2) {
                sort (all(dis[ch]));
                if (dist+wt < dis[ch][1]) {
                    dis[ch].pop_back();
                    dis[ch].pb(dist+wt);
                    q.push({dist+wt, ch});
                }
            }
            else {
                dis[ch].pb(dist+wt);
                q.push({dist+wt, ch});
            }
        }
    }
}
int travel_plan(int n, int m, int (*r)[2], int* l, int k, int *p) {
    return sol(n, m, r, l, k, p);
}

Compilation message

crocodile.cpp: In function 'int sol(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:64:1: warning: control reaches end of non-void function [-Wreturn-type]
   64 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 444 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 596 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 4 ms 852 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 476 ms 57648 KB Output is correct
17 Correct 92 ms 18764 KB Output is correct
18 Correct 113 ms 18436 KB Output is correct
19 Correct 554 ms 63008 KB Output is correct
20 Correct 261 ms 47276 KB Output is correct
21 Correct 46 ms 7472 KB Output is correct
22 Correct 319 ms 45836 KB Output is correct