답안 #753871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
753871 2023-06-06T08:45:32 Z jakobrs Stranded Far From Home (BOI22_island) C++17
10 / 100
191 ms 30168 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Incorrect 2 ms 500 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 178 ms 24992 KB Output is correct
4 Correct 165 ms 27848 KB Output is correct
5 Correct 178 ms 28088 KB Output is correct
6 Correct 191 ms 28952 KB Output is correct
7 Correct 186 ms 29040 KB Output is correct
8 Correct 188 ms 29056 KB Output is correct
9 Correct 176 ms 29184 KB Output is correct
10 Correct 90 ms 26152 KB Output is correct
11 Correct 77 ms 26004 KB Output is correct
12 Correct 184 ms 27664 KB Output is correct
13 Correct 147 ms 28620 KB Output is correct
14 Correct 152 ms 28740 KB Output is correct
15 Correct 186 ms 30168 KB Output is correct
16 Correct 89 ms 29220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Incorrect 166 ms 25804 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 154 ms 24704 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Incorrect 2 ms 500 KB Output isn't correct
5 Halted 0 ms 0 KB -