Submission #722934

# Submission time Handle Problem Language Result Execution time Memory
722934 2023-04-13T05:59:54 Z drdilyor Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 14556 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector s(n, 0);
    for (int& i : s) cin >> i;
    vector<vector<int>> adj(n);
    for (int i = 0; i < m ;i++) {
        int u, v;
        cin >> u >> v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    string res(n, '0');
    for (int i = 0; i < n;i++) {
        vector<int> vis(n);
        set<pair<int,int>> st;
        st.emplace(0, i);
        vis[i]= 1;
        ll sum = s[i];
        while (st.size()) {
            auto [w, i] = *st.begin();
            if (sum < w) break;
            st.erase(st.begin());
            sum += w;
            for (int e : adj[i]) {
                if (!vis[e])
                    vis[e] = 1,
                    st.emplace(s[e], e);
            }
        }
        res[i] |= st.empty();
    }
    cout << res << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 216 ms 408 KB Output is correct
5 Correct 213 ms 404 KB Output is correct
6 Correct 299 ms 388 KB Output is correct
7 Correct 203 ms 396 KB Output is correct
8 Correct 153 ms 380 KB Output is correct
9 Correct 357 ms 456 KB Output is correct
10 Correct 112 ms 340 KB Output is correct
11 Correct 97 ms 404 KB Output is correct
12 Correct 119 ms 340 KB Output is correct
13 Correct 196 ms 340 KB Output is correct
14 Correct 113 ms 424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 1061 ms 14556 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Execution timed out 1067 ms 12852 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Execution timed out 1073 ms 13264 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 216 ms 408 KB Output is correct
5 Correct 213 ms 404 KB Output is correct
6 Correct 299 ms 388 KB Output is correct
7 Correct 203 ms 396 KB Output is correct
8 Correct 153 ms 380 KB Output is correct
9 Correct 357 ms 456 KB Output is correct
10 Correct 112 ms 340 KB Output is correct
11 Correct 97 ms 404 KB Output is correct
12 Correct 119 ms 340 KB Output is correct
13 Correct 196 ms 340 KB Output is correct
14 Correct 113 ms 424 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Execution timed out 1061 ms 14556 KB Time limit exceeded
18 Halted 0 ms 0 KB -