This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
int n, m; cin >> n >> m;
vector<int> s(n+1);
for (int i = 1; i <= n; ++i) cin >> s[i];
vector<vector<int>> ed(n+1);
for (int i = 0; i < m; ++i){
int a, b; cin >> a >> b;
ed[a].push_back(b);
ed[b].push_back(a);
}
string res;
for (int i = 1; i <= n; ++i){
int cursz = s[i];
set<pair<int, int>> st;
vector<bool> visited(n+1); visited[i] = true;
for (auto to : ed[i]) st.insert({s[to], to});
bool flag = true;
while (!st.empty()){
auto it = st.begin();
if (it->first > cursz) {
flag = false;
break;
}
cursz += it->first;
visited[it->second] = true;
for (auto to : ed[it->second]) {
if (visited[to]) continue;
st.insert({s[to], to});
};
st.erase(it);
}
if (flag) res += '1';
else res += '0';
}
cout << res << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |