Submission #600479

# Submission time Handle Problem Language Result Execution time Memory
600479 2022-07-20T22:29:59 Z snasibov05 Stranded Far From Home (BOI22_island) C++14
10 / 100
1000 ms 17792 KB
#include <bits/stdc++.h>

using namespace std;

#define int long long

signed main() {
    int n, m; cin >> n >> m;
    vector<int> s(n+1);
    for (int i = 1; i <= n; ++i) cin >> s[i];
    vector<vector<int>> ed(n+1);
    for (int i = 0; i < m; ++i){
        int a, b; cin >> a >> b;
        ed[a].push_back(b);
        ed[b].push_back(a);
    }

    string res;
    for (int i = 1; i <= n; ++i){
        int cursz = s[i];
        set<pair<int, int>> st;
        vector<bool> visited(n+1); visited[i] = true;
        for (auto to : ed[i]) st.insert({s[to], to});
        bool flag = true;
        while (!st.empty()){
            auto it = st.begin();
            if (it->first > cursz) {
                flag = false;
                break;
            }
            cursz += it->first;
            visited[it->second] = true;
            for (auto to : ed[it->second]) {
                if (visited[to]) continue;
                st.insert({s[to], to});
            };
            st.erase(it);
        }

        if (flag) res += '1';
        else res += '0';
    }

    cout << res << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 240 ms 436 KB Output is correct
5 Correct 227 ms 568 KB Output is correct
6 Correct 402 ms 452 KB Output is correct
7 Correct 242 ms 444 KB Output is correct
8 Correct 192 ms 420 KB Output is correct
9 Correct 333 ms 496 KB Output is correct
10 Correct 131 ms 448 KB Output is correct
11 Correct 127 ms 448 KB Output is correct
12 Correct 123 ms 476 KB Output is correct
13 Correct 222 ms 420 KB Output is correct
14 Correct 123 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 1042 ms 17792 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 1068 ms 16060 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 1069 ms 17444 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 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 240 ms 436 KB Output is correct
5 Correct 227 ms 568 KB Output is correct
6 Correct 402 ms 452 KB Output is correct
7 Correct 242 ms 444 KB Output is correct
8 Correct 192 ms 420 KB Output is correct
9 Correct 333 ms 496 KB Output is correct
10 Correct 131 ms 448 KB Output is correct
11 Correct 127 ms 448 KB Output is correct
12 Correct 123 ms 476 KB Output is correct
13 Correct 222 ms 420 KB Output is correct
14 Correct 123 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Execution timed out 1042 ms 17792 KB Time limit exceeded
18 Halted 0 ms 0 KB -