답안 #849867

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849867 2023-09-15T13:46:10 Z 12345678 Stranded Far From Home (BOI22_island) C++17
0 / 100
1 ms 604 KB
#include <bits/stdc++.h>

using namespace std;

const int nx=1e3+5;

#define ll long long

int n, m, u, v, s[nx];
vector<int> d[nx];
bool vs[nx];

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n>>m;
    for (int i=1; i<=n; i++) cin>>s[i];
    for (int i=1; i<=m; i++) cin>>u>>v, d[u].push_back(v), d[v].push_back(u);
    for (int i=1; i<=n; i++)
    {
        priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
        ll sz=0, cnt=0;
        for (int j=1; j<=n; j++) vs[j]=0;
        pq.push({0, i});
        while (!pq.empty())
        {
            int x=pq.top().first, y=pq.top().second;
            pq.pop();
            if (sz<x||vs[y]) continue;
            vs[y]=1;
            cnt++;
            sz+=s[y];
            for (auto nw:d[y])
            {
                //cout<<i<<' '<<sz<<' '<<nw<<' '<<s[nw]<<'\n';
                pq.push({s[nw], nw});
            }
        }
        if (cnt==n) cout<<1;
        else cout<<0;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Runtime error 1 ms 496 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Runtime error 1 ms 604 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 1 ms 604 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Runtime error 1 ms 496 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -