#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e3 + 25;
vector <int> adj[MAXN];
int cnt[MAXN];
bool vis[MAXN];
int sze;
int main () {
int n, m;
cin >> n >> m;
int l = 0;
for (int i = 1; i <= n; i++) cin >> cnt[i], l += cnt[i];
for (int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int i = 1; i <= n; i++) {
sort(adj[i].begin(), adj[i].end(), [&] (int &a, int &b) {
return cnt[a] < cnt[b];
});
}
for (int i = 1; i <= n; i++) {
sze = cnt[i]; memset(vis, 0, sizeof(vis));
set <pair <int, int>> dd; vis[i] = 1;
for (auto j : adj[i]) dd.insert({cnt[j], j});
while (!dd.empty()) {
auto g = *(dd.begin());
if (g.first > sze) break;
sze += g.first;
dd.erase(g); vis[g.second] = 1;
for (auto j : adj[g.second]) {
if (!vis[j]) dd.insert({cnt[j], j});
}
}
cout << (sze == l);
}
cout << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Runtime error |
4 ms |
496 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
4 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
4 ms |
604 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |