Submission #859071

# Submission time Handle Problem Language Result Execution time Memory
859071 2023-10-09T16:15:45 Z vgtcross Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 13996 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int N = 200200;

vector<int> adj[N];

void solve() {
    int n, m;
    cin >> n >> m;
    
    vector<ll> s(n+1);
    for (int i = 1; i <= n; ++i) cin >> s[i];
    
    for (int i = 0; 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) {
        priority_queue<pll> pq;
        ll sum = 0;
        pq.push({-s[i], i});
        int left = n;
        vector<bool> vis(n, 0);
        while (pq.size()) {
            pll p = pq.top();
            pq.pop();
            if (vis[p.second]) continue;
            
            p.first *= -1;
            if (sum != 0 && sum < p.first) break;
            vis[p.second] = 1;
            --left;
            sum += p.first;
            
            for (int v : adj[p.second]) if (!vis[v]) {
                pq.push({-s[v], v});
            }
        }
        
        cout << (left == 0);
    }
    cout << '\n';
}

int main() {
    cin.tie(0) -> sync_with_stdio(0);
    
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 175 ms 5212 KB Output is correct
5 Correct 132 ms 5212 KB Output is correct
6 Correct 279 ms 5256 KB Output is correct
7 Correct 180 ms 5252 KB Output is correct
8 Correct 146 ms 5248 KB Output is correct
9 Correct 209 ms 5212 KB Output is correct
10 Correct 49 ms 5212 KB Output is correct
11 Correct 52 ms 5256 KB Output is correct
12 Correct 47 ms 5248 KB Output is correct
13 Correct 86 ms 5212 KB Output is correct
14 Correct 83 ms 5244 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Execution timed out 1051 ms 13996 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Execution timed out 1079 ms 12900 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Execution timed out 1043 ms 13420 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 175 ms 5212 KB Output is correct
5 Correct 132 ms 5212 KB Output is correct
6 Correct 279 ms 5256 KB Output is correct
7 Correct 180 ms 5252 KB Output is correct
8 Correct 146 ms 5248 KB Output is correct
9 Correct 209 ms 5212 KB Output is correct
10 Correct 49 ms 5212 KB Output is correct
11 Correct 52 ms 5256 KB Output is correct
12 Correct 47 ms 5248 KB Output is correct
13 Correct 86 ms 5212 KB Output is correct
14 Correct 83 ms 5244 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Execution timed out 1051 ms 13996 KB Time limit exceeded
18 Halted 0 ms 0 KB -