Submission #290865

# Submission time Handle Problem Language Result Execution time Memory
290865 2020-09-04T14:06:22 Z Fischer Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
973 ms 54328 KB
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;

const int maxn = 1e5 + 10;
int d[maxn];
int need[maxn];
using ii = pair<int, int>;
vector<int> g[maxn];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]) {
    for (int i = 0; i < M; ++i) {
        int u = R[i][0], v = R[i][1];
        g[u].emplace_back(i);
        g[v].emplace_back(i);
    }
    for (int i = 0; i < N; ++i) {
        need[i]= 2;
    }
    priority_queue<ii, vector<ii>, greater<ii>> q;
    for (int i = 0; i < K; ++i) {
        q.emplace(0, P[i]);
        need[P[i]] = 1;
    }
    int ans = -1;
    while (!q.empty()) {
        auto e = q.top(); q.pop();
        need[e.second] -= 1;
        if (need[e.second] != 0) continue;
        if (e.second == 0) ans = e.first;
        for (int ie : g[e.second]) {
            int temp = e.first + L[ie];
            int v = e.second ^ R[ie][0] ^ R[ie][1];
            if (need[v] <= 0) continue;
            q.emplace(temp, v);
        }
    }
    return ans;
}

/**
int n, m, k;
int R[maxn][2];
int L[maxn];
int P[maxn];

int main() {
    
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i) cin >> R[i][0] >> R[i][1];
    for (int i = 0; i < m; ++i) cin >> L[i];
    for (int i = 0; i < k; ++i) cin >> P[i];
    cout << travel_plan(n, m, R, L, k, P) << endl;
    return 0;
}
**/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 6 ms 2944 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 7 ms 3200 KB Output is correct
13 Correct 7 ms 3200 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 3 ms 2816 KB Output is correct
5 Correct 3 ms 2816 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2816 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 6 ms 2944 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2816 KB Output is correct
12 Correct 7 ms 3200 KB Output is correct
13 Correct 7 ms 3200 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 3 ms 2816 KB Output is correct
16 Correct 878 ms 52108 KB Output is correct
17 Correct 94 ms 11768 KB Output is correct
18 Correct 139 ms 12820 KB Output is correct
19 Correct 973 ms 54328 KB Output is correct
20 Correct 539 ms 47208 KB Output is correct
21 Correct 46 ms 6648 KB Output is correct
22 Correct 500 ms 37368 KB Output is correct