#include <bits/stdc++.h>
#define int long long
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();
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';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Correct |
4 ms |
6484 KB |
Output is correct |
3 |
Correct |
3 ms |
6484 KB |
Output is correct |
4 |
Correct |
219 ms |
6612 KB |
Output is correct |
5 |
Correct |
226 ms |
6828 KB |
Output is correct |
6 |
Correct |
256 ms |
6708 KB |
Output is correct |
7 |
Correct |
234 ms |
6612 KB |
Output is correct |
8 |
Correct |
156 ms |
6612 KB |
Output is correct |
9 |
Incorrect |
269 ms |
6740 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Correct |
3 ms |
6484 KB |
Output is correct |
3 |
Execution timed out |
1075 ms |
16568 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Execution timed out |
1065 ms |
14256 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
6484 KB |
Output is correct |
2 |
Execution timed out |
1078 ms |
15780 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
6484 KB |
Output is correct |
2 |
Correct |
4 ms |
6484 KB |
Output is correct |
3 |
Correct |
3 ms |
6484 KB |
Output is correct |
4 |
Correct |
219 ms |
6612 KB |
Output is correct |
5 |
Correct |
226 ms |
6828 KB |
Output is correct |
6 |
Correct |
256 ms |
6708 KB |
Output is correct |
7 |
Correct |
234 ms |
6612 KB |
Output is correct |
8 |
Correct |
156 ms |
6612 KB |
Output is correct |
9 |
Incorrect |
269 ms |
6740 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |