답안 #722882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722882 2023-04-13T04:21:52 Z MDSPro Stranded Far From Home (BOI22_island) C++17
0 / 100
511 ms 17532 KB
#include "bits/stdc++.h"

using namespace std;

int main(){
    int n,m; cin >> n >> m;
    vector<int> 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<int,int>> st;
        st.insert({0,i}); vis[i] = i;

        int 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;
    }
}
# 결과 실행 시간 메모리 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 Incorrect 4 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 511 ms 17368 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 327 ms 17308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 463 ms 17532 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 4 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -