답안 #850408

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850408 2023-09-16T14:08:05 Z MinaRagy06 Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 12936 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;

const int N = 200'005;
bool in[N];
vector<int> adj[N];
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m;
    cin >> n >> m;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0, u, v; i < m; i++) {
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (int st = 0; st < n; st++) {
        for (int i = 0; i < n; i++) {
            in[i] = 0;
        }
        in[st] = 1;
        priority_queue<pair<int, int>> pq;
        for (auto nxt : adj[st]) {
            pq.push({-a[nxt], nxt});
        }
        ll ttl = a[st];
        while (pq.size()) {
            int cost = -pq.top().first;
            int node = pq.top().second;
            pq.pop();
            if (in[node]) continue;
            if (ttl < cost) {
                break;
            }
            ttl += cost;
            in[node] = 1;
            for (auto nxt : adj[node]) {
                if (!in[nxt]) {
                    pq.push({-a[nxt], nxt});
                }
            }
        }
        int ok = 1;
        for (int i = 0; i < n; i++) {
            ok &= in[i];
        }
        cout << ok;
    }
    cout << '\n';
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 176 ms 5412 KB Output is correct
5 Correct 131 ms 5208 KB Output is correct
6 Correct 270 ms 5232 KB Output is correct
7 Correct 189 ms 5208 KB Output is correct
8 Correct 142 ms 5456 KB Output is correct
9 Correct 202 ms 5248 KB Output is correct
10 Correct 45 ms 5244 KB Output is correct
11 Correct 45 ms 5244 KB Output is correct
12 Correct 46 ms 5212 KB Output is correct
13 Correct 76 ms 5212 KB Output is correct
14 Correct 88 ms 5456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Execution timed out 1048 ms 12936 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Execution timed out 1047 ms 12112 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Execution timed out 1044 ms 12280 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 176 ms 5412 KB Output is correct
5 Correct 131 ms 5208 KB Output is correct
6 Correct 270 ms 5232 KB Output is correct
7 Correct 189 ms 5208 KB Output is correct
8 Correct 142 ms 5456 KB Output is correct
9 Correct 202 ms 5248 KB Output is correct
10 Correct 45 ms 5244 KB Output is correct
11 Correct 45 ms 5244 KB Output is correct
12 Correct 46 ms 5212 KB Output is correct
13 Correct 76 ms 5212 KB Output is correct
14 Correct 88 ms 5456 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4952 KB Output is correct
17 Execution timed out 1048 ms 12936 KB Time limit exceeded
18 Halted 0 ms 0 KB -