Submission #753871

#TimeUsernameProblemLanguageResultExecution timeMemory
753871jakobrsStranded Far From Home (BOI22_island)C++17
10 / 100
191 ms30168 KiB
#include <iostream> #include <vector> #include <queue> #include <tuple> #include <utility> using i64 = int64_t; int main() { std::cin.tie(nullptr)->sync_with_stdio(false); i64 n, m; std::cin >> n >> m; std::vector<i64> a(n); for (i64 i = 0; i < n; i++) std::cin >> a[i]; std::vector<std::vector<i64>> adj(n); std::vector<std::vector<i64>> children(n); for (i64 i = 0; i < m; i++) { i64 u, v; std::cin >> u >> v; u--, v--; adj[u].push_back(v); adj[v].push_back(u); children[std::min(u, v)].push_back(std::max(u, v)); } std::string result(n, '0'); std::vector<i64> sizes(n); for (i64 i = n - 1; i >= 0; i--) { sizes[i] = a[i]; for (i64 j : children[i]) { sizes[i] += sizes[j]; } } result[0] = '1'; for (i64 i = 0; i < n; i++) { if (result[i] == '1') { for (i64 j : children[i]) { if (sizes[j] >= a[i]) { result[j] = '1'; } } } } std::cout << result; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...