답안 #711052

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
711052 2023-03-16T07:46:08 Z safaricola Stranded Far From Home (BOI22_island) C++17
0 / 100
3 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 1; i <= n; i++)
#define ii pair<int,int>
#define f first
#define s second
#define pb push_back
#define debug(x) cout<<#x<<' '<<x<<endl;

vector<int> adj[2010];
int n,m,a[2010];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    rep(i,n)cin>>a[i];
    rep(i,m){
        int A,B;cin>>A>>B;
        adj[A].pb(B);
        adj[B].pb(A);
    }
    rep(i,n){
        bool vis[2010]={};
        int cur=a[i];
        priority_queue<ii,vector<ii>, greater<ii> > pq;
        pq.push({0,i});
        vis[i]=1;
        while(!pq.empty()&&pq.top().f<=cur){
            cur+=pq.top().f;
            int v=pq.top().s;
            pq.pop();
            for(int u: adj[v]){
                if(!vis[u]){
                    vis[u]=1;
                    pq.push({a[u],u});
                }
            }
        }
        if(pq.empty())cout<<1;else cout<<0;
    }
    
}
/*
4 4
2 2 4 3  
1 2
1 3
2 3
3 4

4 3 
4 2 2 1 
1 2
3 2
4 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Runtime error 2 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Runtime error 3 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Runtime error 2 ms 468 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Incorrect 2 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -