Submission #1097417

# Submission time Handle Problem Language Result Execution time Memory
1097417 2024-10-07T08:47:46 Z HaciyevAlik Stranded Far From Home (BOI22_island) C++14
10 / 100
304 ms 632 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define oo 100000000000000000
const int mx = 2005;

int s[mx];
vector<int> g[mx];

signed main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,m; cin >> n >> m;
    for(int i = 1; i <= n; ++i) {
        cin >> s[i];
    }
    for(int i = 1; i <= m; ++i) {
        int u,v; cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 1; i <= n; ++i) {
        priority_queue<pair<int,int>> pq;
        vector<bool> used(n + 1, 0);
        used[i] = true;
        int val = s[i];
        for(int v : g[i]) {
            pq.push({-s[v], v});
        }
        while(!pq.empty() && -pq.top().first <= val) {
            int v = pq.top().second;
            used[v] = 1;
            val += (-pq.top().first);
            pq.pop();   
            for(int go : g[v]) {
                if(!used[go]) {
                    pq.push({-s[go], go});
                }
            }
        }
        int cnt = 0;
        for(int j = 1; j <= n; ++j) {
            cnt += used[j];
        }
        if(cnt == n) {
            cout << "1";
        } else {
            cout << "0";
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 176 ms 620 KB Output is correct
5 Correct 114 ms 556 KB Output is correct
6 Correct 304 ms 600 KB Output is correct
7 Correct 194 ms 604 KB Output is correct
8 Correct 154 ms 600 KB Output is correct
9 Correct 182 ms 632 KB Output is correct
10 Correct 49 ms 552 KB Output is correct
11 Correct 45 ms 600 KB Output is correct
12 Correct 42 ms 604 KB Output is correct
13 Correct 80 ms 604 KB Output is correct
14 Correct 71 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 176 ms 620 KB Output is correct
5 Correct 114 ms 556 KB Output is correct
6 Correct 304 ms 600 KB Output is correct
7 Correct 194 ms 604 KB Output is correct
8 Correct 154 ms 600 KB Output is correct
9 Correct 182 ms 632 KB Output is correct
10 Correct 49 ms 552 KB Output is correct
11 Correct 45 ms 600 KB Output is correct
12 Correct 42 ms 604 KB Output is correct
13 Correct 80 ms 604 KB Output is correct
14 Correct 71 ms 604 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Runtime error 1 ms 604 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -