답안 #727068

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
727068 2023-04-20T02:48:33 Z NeroZein Stranded Far From Home (BOI22_island) C++17
0 / 100
1000 ms 12844 KB
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;

const int N = 200005;

int a[N];
int vis[N];
vector<int> g[N];

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < m; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u); 
	}
	auto dij = [&](int src) {
		priority_queue<pii, vector<pii>, greater<pii>> que;
		que.emplace(0, src);
		int cur = 0; 
		vis[src] = true;
		while (!que.empty()) {
			auto [c, v] = que.top();
			que.pop();
			//cout << " " << src << ' ' << v << '\n';
			if (c > cur) {
				break; 
			} 
			cur += a[v]; 
			for (int u : g[v]) {
				if (!vis[u]) {
					que.emplace(a[u], u);
					vis[u] = true;
				}
			}
		}
	};
	for (int i = 1; i <= n; ++i) {
		memset(vis, 0, sizeof vis); 
		dij(i);
		bool ok = true;
		for (int j = 1; j <= n; ++j) {
			ok &= vis[j];
		}
		//cout << '\n';
		cout << ok;
	}
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Correct 3 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Incorrect 38 ms 5844 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Correct 3 ms 5716 KB Output is correct
3 Execution timed out 1090 ms 12844 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Execution timed out 1076 ms 12788 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Execution timed out 1072 ms 12844 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 5716 KB Output is correct
2 Correct 3 ms 5716 KB Output is correct
3 Correct 3 ms 5716 KB Output is correct
4 Incorrect 38 ms 5844 KB Output isn't correct
5 Halted 0 ms 0 KB -