#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
428 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
204 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |