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;
using ll = long long;
const int N = 111;
vector<int> adj[N];
vector<vector<int>> mu[N];
int deg[N];
ll dp[N];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int g, n, m;
cin >> g >> n >> m;
for (int i = 1;i <= n;i++) {
int a, k;
cin >> a >> k;
vector<int> mut(k);
for (auto& x : mut) cin >> x;
mu[a].push_back(mut);
}
memset(dp, 0x3f, sizeof dp);
dp[0] = dp[1] = 1;
for (int _ = 1;_ <= g + 1;_++) {
for (int i = 2;i < g;i++) {
for (auto& x : mu[i]) {
ll res = 0;
for (auto& y : x) res += dp[y];
dp[i] = min(dp[i], res);
}
}
}
for (int i = 2;i < g;i++) {
if (dp[i] > 1e9) cout << "YES\n";
else cout << "NO " << dp[i] << '\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... |