#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define lli long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
lli g,n,m,a,b,c;
lli res[200];
vector<lli> gen[200],borr[200],anti[100];
void DFS(lli act) {
res[act] = -1;
bool YES = false;
lli sum = 0;
for (auto h : gen[act]) {
if (h == 0 || h == 1) {
sum++;
borr[act].push_back(h);
continue;
}
if (res[h] == 0) DFS(h);
if (res[h] < 0) {YES = true; break;}
else {
sum += res[h];
for (auto k : borr[h]) borr[act].push_back(k);
}
}
debug(act);
for (auto r : borr[act]) cout << r << ' ';
cout << endl;
if (YES) {
res[act] = -2;
return;
}
rep(i,1,m) {
if (anti[i].size() > borr[act].size()) continue;
rep(j,0,borr[act].size() - anti[i].size()) {
bool igual = true;
rep(k,j,j+anti[i].size()-1) {
if (borr[act][k] != anti[i][k-j]) igual = false;
}
if (igual) {
res[act] = -2;
return;
}
}
}
res[act] = sum;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> g >> n >> m;
rep(j,1,n) {
cin >> a >> b;
rep(i,1,b) {
cin >> c;
gen[a].push_back(c);
}
}
rep(i,1,m) {
cin >> a;
rep(j,1,a) {
cin >> b;
anti[i].push_back(b);
}
}
rep(i,2,g-1) if(res[i] == 0) DFS(i);
rep(i,2,g-1) {
if (res[i] < 0) cout << "YES\n";
else cout << "NO " << res[i] << "\n";
}
}
Compilation message
Viruses.cpp: In function 'void DFS(long long int)':
Viruses.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
Viruses.cpp:47:9: note: in expansion of macro 'rep'
47 | rep(j,0,borr[act].size() - anti[i].size()) {
| ^~~
Viruses.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
Viruses.cpp:49:13: note: in expansion of macro 'rep'
49 | rep(k,j,j+anti[i].size()-1) {
| ^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |