답안 #722960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722960 2023-04-13T06:28:09 Z rshohruh Stranded Far From Home (BOI22_island) C++14
0 / 100
1000 ms 20568 KB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> s;
vector<bool> used;
class Compare{
public:
    bool operator () (int a, int b){
        return s[a] > s[b];
    }
};
priority_queue<int, vector<int>, Compare> b;
int n;
char bfs(int u){
    used.assign(n+1, false);
    int cnt = s[u];
    used[u] = true;
    for(int v: g[u]){
        b.push(v);
        used[v] = true;
    }
    while(!b.empty()){
        u = b.top();
        b.pop();
        if(s[u] > cnt) return '0';
        cnt += s[u];
        for(int v: g[u]){
            if(!used[v]){
                b.push(v);
                used[v] = true;
            }
        }
    }
    return '1';
}

int main(){
    int m;
    cin >> n >> m;
    s.resize(n+1);
    g.resize(n+1);
    for(int i = 1; i <= n; ++i) cin >> s[i];
    for(int i = 0, u, v; i < m; ++i){
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 1; i <= n; ++i) cout << bfs(i);
}
# 결과 실행 시간 메모리 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 5 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Execution timed out 1089 ms 14264 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 553 ms 14280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 903 ms 20568 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 5 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -