# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
286200 | spdskatr | Viruses (BOI20_viruses) | C++14 | 1 ms | 256 KiB |
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 <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int G, N, M;
long long dp[105];
vector<int> rec[105];
vector<int> mut[105];
vector<int> nice[105];
int main() {
scanf("%d %d %d", &G, &N, &M);
for (int i = 0; i < N; i++) {
int a, k;
scanf("%d %d", &a, &k);
rec[a].push_back(i);
for (int j = 0; j < k; j++) {
int v;
scanf("%d", &v);
mut[i].push_back(v);
}
}
dp[0] = dp[1] = 1;
for (int i = 2; i < G; i++) dp[i] = -1;
for (int t = 0; t < G; t++) {
for (int g = 2; g < G; g++) {
for (int i : rec[g]) {
int rip = 0;
long long val = 0;
for (int v : mut[i]) {
if (dp[v] == -1) rip = 1;
val += dp[v];
}
if (rip) continue;
if (dp[g] == -1) dp[g] = val;
else dp[g] = min(dp[g], val);
}
}
}
for (int i = 2; i < G; i++) {
if (dp[i] == -1) {
printf("YES\n");
} else {
printf("NO %lld\n", dp[i]);
}
}
}
Compilation message (stderr)
# | 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... |