Submission #799016

# Submission time Handle Problem Language Result Execution time Memory
799016 2023-07-31T08:41:35 Z M7kra Cyberland (APIO23_cyberland) C++17
8 / 100
28 ms 7344 KB
#include "cyberland.h"
#include <iostream>
#include <queue>
using namespace std;

typedef pair<int, int> pii;
typedef pair<double, int> pdd;
double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    
    vector<vector<pii>> adjacent(N);
    for (int i = 0; i < M; i++) {
        adjacent[x[i]].push_back({y[i], c[i]});
        adjacent[y[i]].push_back({x[i], c[i]});
    }

    priority_queue<pdd, vector<pdd>, greater<pdd>> pq;

    queue<int> q;
    vector<bool> visited(N);
    vector<bool> visited2(N);
    q.push(0);
    visited[0] = true;
    arr[0] = 0;
    while (!q.empty()) {
        int vertex = q.front();
        q.pop();
    
        if (arr[vertex] == 0) {
            pq.push({0, vertex});
            visited2[vertex] = true;
        }
        for (pii v : adjacent[vertex]) {
            if (visited[v.first]) continue;
            visited[v.first] = true;
            q.push(v.first);
        }
    }

    while (!pq.empty()) {
        pdd vertex = pq.top();
        pq.pop();

        if (vertex.second == H) return vertex.first;
        for (pdd v : adjacent[vertex.second]) {
            if (visited2[v.first]) continue;
            visited2[v.first] = true;
            pq.push({vertex.first + v.second, v.first});
        }
    }
    return -1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 724 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 1312 KB Correct.
2 Correct 22 ms 1424 KB Correct.
3 Correct 20 ms 1324 KB Correct.
4 Correct 23 ms 1356 KB Correct.
5 Correct 26 ms 1484 KB Correct.
6 Correct 26 ms 2092 KB Correct.
7 Correct 23 ms 2280 KB Correct.
8 Correct 10 ms 2564 KB Correct.
9 Correct 21 ms 1256 KB Correct.
10 Correct 21 ms 1256 KB Correct.
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 1464 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 7344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 1372 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1356 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1320 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 1412 KB Wrong Answer.
2 Halted 0 ms 0 KB -