#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 |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |