답안 #948797

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
948797 2024-03-18T14:31:02 Z ifateen Stranded Far From Home (BOI22_island) C++17
10 / 100
164 ms 884 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 2003;
vector<int> adj[MAXN];
int population[MAXN];

bool djikstra(int start) {
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<>> pq;
    pq.emplace(0, start);
    int have = population[start];
    vector<bool> vis(MAXN);
    vis[start] = true;
    while (!pq.empty()) {
        auto [need, u] = pq.top();
        pq.pop();
        if (have >= need) have += need;
        else return false;
        for (auto& v : adj[u]) {
            if (vis[v]) continue;
            vis[v] = true;
            pq.emplace(population[v], v);
        }
    }
    return true;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) cin >> population[i];
    for (int i = 1; i <= m; ++i) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int i = 1; i <= n; ++i) cout << djikstra(i);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 133 ms 624 KB Output is correct
5 Correct 128 ms 600 KB Output is correct
6 Correct 164 ms 612 KB Output is correct
7 Correct 127 ms 624 KB Output is correct
8 Correct 89 ms 604 KB Output is correct
9 Correct 153 ms 600 KB Output is correct
10 Correct 30 ms 620 KB Output is correct
11 Correct 29 ms 604 KB Output is correct
12 Correct 33 ms 604 KB Output is correct
13 Correct 58 ms 348 KB Output is correct
14 Correct 72 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 860 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 884 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 860 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 133 ms 624 KB Output is correct
5 Correct 128 ms 600 KB Output is correct
6 Correct 164 ms 612 KB Output is correct
7 Correct 127 ms 624 KB Output is correct
8 Correct 89 ms 604 KB Output is correct
9 Correct 153 ms 600 KB Output is correct
10 Correct 30 ms 620 KB Output is correct
11 Correct 29 ms 604 KB Output is correct
12 Correct 33 ms 604 KB Output is correct
13 Correct 58 ms 348 KB Output is correct
14 Correct 72 ms 604 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Runtime error 1 ms 860 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -