Submission #395428

# Submission time Handle Problem Language Result Execution time Memory
395428 2021-04-28T10:45:03 Z KoD Viruses (BOI20_viruses) C++17
11 / 100
1 ms 424 KB
#include <bits/stdc++.h>

template <class T>
using Vec = std::vector<T>;

using ll = long long;

int main() {
    int G, N, M;
    std::cin >> G >> N >> M;
    Vec<Vec<Vec<int>>> graph(G);
    while (N--) {
        int a, k;
        std::cin >> a >> k;
        Vec<int> b(k);
        for (auto& x: b) {
            std::cin >> x;
        }
        graph[a].push_back(std::move(b));
    }
    assert(M == 0);
    Vec<ll> shortest(G, -1);
    shortest[0] = shortest[1] = 1;
    while (true) {
        bool change = false;
        for (int i = 2; i < G; ++i) {
            for (const auto& v: graph[i]) {
                ll sum = 0;
                for (const auto x: v) {
                    if (shortest[x] == -1) {
                        sum = -1;
                        break;
                    }
                    sum += shortest[x];
                }
                if (sum != -1 and (shortest[i] == -1 or shortest[i] > sum)) {
                    shortest[i] = sum;
                    change = true;
                }
            }
        }
        if (!change) {
            break;
        }
    }
    for (int i = 2; i < G; ++i) {
        if (shortest[i] == -1) {
            std::cout << "YES\n";
        }
        else {
            std::cout << "NO " << shortest[i] << '\n';
        }
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Runtime error 1 ms 332 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Runtime error 1 ms 424 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 300 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 292 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Runtime error 1 ms 332 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -