답안 #987206

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987206 2024-05-22T10:43:43 Z batsukh2006 Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 21324 KB
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<string.h>
#include<utility>
#include<set>
#include<cmath>
#include<queue>
#include<deque>
#include<functional>
#include<stack>
#include<limits.h>
#include<iomanip>
#include<unordered_map> 
#include<numeric>
#include<tuple>
#include<bitset>
using namespace std;
 
#define MOD 1000000007
#define int long long
#define ss second
#define ff first
#define endl '\n'
typedef pair<int,int> pp;
void solve(){
	int n,m; cin>>n>>m;
	vector<int> v[n+1],s(n+1);
	for(int i=1; i<=n; i++) cin>>s[i];
	for(int i=1; i<=m; i++){
		int a,b; cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	int need=0;
	vector<int> dp(n+1);
	for(int i=1; i<=n; i++){
		priority_queue<pp,vector<pp>,greater<pp> > q;
		vector<bool> vis(n+1);
		q.push({s[i],i});
		need+=s[i];
		vis[i]=1;
		while(!q.empty()){
			int w=q.top().ff;
			int a=q.top().ss;
			if(w>dp[i]&&a!=i) break;
			dp[i]+=w;
			q.pop();
			for(auto node: v[a]){
				if(!vis[node]){
					vis[node]=1;
					q.push({s[node],node});
				}
			}
		}
	}
	for(int i=1; i<=n; i++){
		if(dp[i]==need) cout<<1;
		else cout<<0;
	}
}
signed main(){
    // freopen("file.in", "r", stdin);
    // freopen("file.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
    // cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 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 Correct 138 ms 616 KB Output is correct
5 Correct 130 ms 600 KB Output is correct
6 Correct 172 ms 616 KB Output is correct
7 Correct 137 ms 616 KB Output is correct
8 Correct 94 ms 604 KB Output is correct
9 Correct 198 ms 644 KB Output is correct
10 Correct 49 ms 608 KB Output is correct
11 Correct 47 ms 604 KB Output is correct
12 Correct 51 ms 632 KB Output is correct
13 Correct 91 ms 852 KB Output is correct
14 Correct 78 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Execution timed out 1008 ms 21324 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 504 KB Output is correct
2 Execution timed out 1068 ms 18720 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Execution timed out 1055 ms 20432 KB Time limit exceeded
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 Correct 138 ms 616 KB Output is correct
5 Correct 130 ms 600 KB Output is correct
6 Correct 172 ms 616 KB Output is correct
7 Correct 137 ms 616 KB Output is correct
8 Correct 94 ms 604 KB Output is correct
9 Correct 198 ms 644 KB Output is correct
10 Correct 49 ms 608 KB Output is correct
11 Correct 47 ms 604 KB Output is correct
12 Correct 51 ms 632 KB Output is correct
13 Correct 91 ms 852 KB Output is correct
14 Correct 78 ms 604 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Execution timed out 1008 ms 21324 KB Time limit exceeded
18 Halted 0 ms 0 KB -