답안 #722933

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
722933 2023-04-13T05:57:15 Z yahyobekabdunazarov Stranded Far From Home (BOI22_island) C++17
0 / 100
1000 ms 12436 KB
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
const int MAX_N = 2e5 + 9;
vector<int> adj[MAX_N], weights(MAX_N);

bool visited[MAX_N];
priority_queue <pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq;
void add_children(int u){
	for(int i: adj[u]){
		if(visited[i]) continue;
		pq.push(make_pair(weights[i], i)); 
	}
}
int main() {
    int n, m, right = 0;
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
		cin >> weights[i];
		right += weights[i];
	}
    for(int i = 0; i < m; i++){
		int x, y;
		cin >> x >> y;
		adj[y].push_back(x);
		adj[x].push_back(y);
	}
	for(int i = 1; i <= n; i++){
		int sum = weights[i];
		visited[i] = 1;
		add_children(i);
		while(!pq.empty() && pq.top().ff <= sum){			
			visited[pq.top().ss] = 1;
			sum += pq.top().ff;
			pq.pop();
			add_children(pq.top().ss);
		}
		cout << (sum == right);
		pq = priority_queue <pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>();
		fill(visited, visited + MAX_N, false);
		
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5972 KB Output is correct
2 Correct 3 ms 5972 KB Output is correct
3 Correct 3 ms 5972 KB Output is correct
4 Incorrect 13 ms 5972 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 5972 KB Output is correct
2 Correct 3 ms 5972 KB Output is correct
3 Execution timed out 1080 ms 12436 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5972 KB Output is correct
2 Execution timed out 1071 ms 12308 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5972 KB Output is correct
2 Execution timed out 1075 ms 12388 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5972 KB Output is correct
2 Correct 3 ms 5972 KB Output is correct
3 Correct 3 ms 5972 KB Output is correct
4 Incorrect 13 ms 5972 KB Output isn't correct
5 Halted 0 ms 0 KB -