답안 #685584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
685584 2023-01-24T15:09:40 Z stanislavpolyn Viruses (BOI20_viruses) C++17
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define fe(x, y) for (auto& x : y)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pw(x) (1LL << (x))

using namespace std;

mt19937_64 rng(228);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

template <typename T>
bool umn(T& a, T b) {
    return a > b ? a = b, 1 : 0;
}
template <typename T>
bool umx(T& a, T b) {
    return a < b ? a = b, 1 : 0;
}

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;

const int N = 105;

int G, n, m;
ve<ve<int>> from[N];

ll dp[N];
bool vis[N];

ll go(int v) {
    if (vis[v]) {
        return dp[v];
    }
    vis[v] = 1;

    ll best = 1e18;
    fe (x, from[v]) {
        ll sum = 0;
        fe (to, x) {
            sum += go(to);
            umn(sum, ll(1e18));
        }

        umn(best, sum);
    }
    dp[v] = best;
    return best;
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    cin >> G >> n >> m;

    fr (i, 1, n) {
        int a, k;
        cin >> a >> k;

        ve<int> v;
        fr (j, 1, k) {
            int x;
            cin >> x;
            v.pb(x);
        }
        from[a].pb(v);
    }

    fr (i, 2, G - 1) {
        dp[i] = 1e18;
    }

    vis[0] = vis[1] = 1;
    dp[0] = dp[1] = 1;

    fr (i, 2, G - 1) {
        ll val = go(i);
        if (val == 1e18) {
            cout << "YES\n";
        } else {
            cout << "NO " << val << "\n";
        }
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -