Submission #722883

# Submission time Handle Problem Language Result Execution time Memory
722883 2023-04-13T04:26:33 Z MDSPro Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 15500 KB
#include "bits/stdc++.h"

using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<long long> a(n+1); for(int i = 1; i <= n; ++i) cin >> a[i];
    
    vector<vector<int>> g(n+1);
    for(int i = 0; i < m; ++i){
        int x,y; cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }

    vector<int> vis(n+1,0);
    for(int i = 1; i <= n; ++i){
        set<pair<long long,int>> st;
        st.insert({0,i}); vis[i] = i;

        long long cur = 0;
        while(!st.empty()){
            auto [cnt,x] = *st.begin();
            if(cnt > cur) break;
            st.erase(st.begin());
            cur += a[x];
            for(int z: g[x]){
                if(vis[z] != i) {
                    vis[z] = i;
                    st.insert({a[z],z});
                }
            }
        }

        if(st.empty()) cout << 1;
        else cout << 0;
    }
}
# 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 203 ms 420 KB Output is correct
5 Correct 201 ms 352 KB Output is correct
6 Correct 296 ms 460 KB Output is correct
7 Correct 196 ms 340 KB Output is correct
8 Correct 148 ms 424 KB Output is correct
9 Correct 320 ms 516 KB Output is correct
10 Correct 98 ms 468 KB Output is correct
11 Correct 94 ms 448 KB Output is correct
12 Correct 119 ms 340 KB Output is correct
13 Correct 192 ms 440 KB Output is correct
14 Correct 115 ms 440 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 1078 ms 15500 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 1076 ms 13540 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 1063 ms 13876 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 203 ms 420 KB Output is correct
5 Correct 201 ms 352 KB Output is correct
6 Correct 296 ms 460 KB Output is correct
7 Correct 196 ms 340 KB Output is correct
8 Correct 148 ms 424 KB Output is correct
9 Correct 320 ms 516 KB Output is correct
10 Correct 98 ms 468 KB Output is correct
11 Correct 94 ms 448 KB Output is correct
12 Correct 119 ms 340 KB Output is correct
13 Correct 192 ms 440 KB Output is correct
14 Correct 115 ms 440 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 1078 ms 15500 KB Time limit exceeded
18 Halted 0 ms 0 KB -