#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > g;
vector<int> s;
vector<bool> used;
queue<int> b;
int n;
char bfs(int u){
int cnt = s[u];
used.assign(n+1, false);
b.push(u);
while(!b.empty()){
u = b.front();
b.pop();
for(auto v: g[u]){
if(s[v] > cnt) return '0';
cnt += s[v];
}
}
return '1';
}
int main(){
int m;
cin >> n >> m;
s.resize(n+1);
g.resize(n+1);
for(int i = 1; i <= n; ++i) cin >> s[i];
for(int i = 0, u, v; i < m; ++i){
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int i = 1; i <= n; ++i){
sort(g[i].begin(), g[i].end(), [&](int a, int b){
return s[a] < s[b];
});
}
for(int i = 1; i <= n; ++i) cout << bfs(i);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
462 ms |
12168 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
433 ms |
12052 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
494 ms |
12224 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
4 ms |
340 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |