답안 #911034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911034 2024-01-18T11:32:47 Z pragmatist Stranded Far From Home (BOI22_island) C++17
10 / 100
1000 ms 17956 KB
/*
JUDGE_ID : 331438IX
*/

#include<iostream>
#include<cassert>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<set>
#include<queue>
#include<map>

using namespace std;

const int N = (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int MOD = (int)998244353;
const long long INF = (long long)1e18 + 7; 

int mult(int x, int y) {
	return 1ll*x*y%MOD;
}

int sum(int x, int y) {
	x += y;
	if(x >= MOD) {
		x -= MOD;
	}
	return x;
}

int sub(int x, int y) {
	x -= y;
	if(x < 0) {
		x += MOD;
	}
	return x;
}

bool is_prime(int x) {
	if(x == 1) {
		return 0;
	}
	for(int i = 2; i * i <= x; ++i) {
		if(x % i == 0) {
			return 0;
		}
	}
	return 1;
}

int n, m, a[N];
vector<int> g[N];
bool used[N];

int main() {	
	ios_base::sync_with_stdio(NULL);
	cin.tie(0);         
	cin >> n >> m;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for(int i = 1; i <= m; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}                         
	for(int s = 1; s <= n; ++s) {
		fill(used+1, used+1+n, 0);
		long long cur = a[s];
		priority_queue<pair<long long, int> > q;
		for(auto x : g[s]) {
			used[x] = 1;
			q.push({-a[x], x});
		}
		used[s] = 1;
		int cnt = 0;
		while(!q.empty()) {
			int v = q.top().second;
			q.pop();
			if(cur >= a[v]) {
				cnt++;
				cur += a[v];
				for(auto to : g[v]) {
					if(!used[to]) {
						used[to] = 1;
						q.push({-a[to], to});	
					}			
				}
			}			
		}
		cout << (cnt == n-1);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 164 ms 5212 KB Output is correct
5 Correct 132 ms 5272 KB Output is correct
6 Correct 201 ms 5260 KB Output is correct
7 Correct 140 ms 5220 KB Output is correct
8 Correct 104 ms 5248 KB Output is correct
9 Correct 273 ms 5296 KB Output is correct
10 Correct 54 ms 5268 KB Output is correct
11 Correct 50 ms 5208 KB Output is correct
12 Correct 46 ms 5212 KB Output is correct
13 Correct 95 ms 5252 KB Output is correct
14 Correct 83 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Execution timed out 1069 ms 17956 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Execution timed out 1031 ms 16588 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Execution timed out 1060 ms 17060 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4952 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 164 ms 5212 KB Output is correct
5 Correct 132 ms 5272 KB Output is correct
6 Correct 201 ms 5260 KB Output is correct
7 Correct 140 ms 5220 KB Output is correct
8 Correct 104 ms 5248 KB Output is correct
9 Correct 273 ms 5296 KB Output is correct
10 Correct 54 ms 5268 KB Output is correct
11 Correct 50 ms 5208 KB Output is correct
12 Correct 46 ms 5212 KB Output is correct
13 Correct 95 ms 5252 KB Output is correct
14 Correct 83 ms 5212 KB Output is correct
15 Correct 2 ms 4952 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Execution timed out 1069 ms 17956 KB Time limit exceeded
18 Halted 0 ms 0 KB -