이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
lli g,n,m,a,b,c,MAX;
lli res[102];
vector<lli> gen[102],borr[102],anti[52];
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);
}
}
if (YES) {
res[act] = -2;
return;
}
if (borr[act].size() > MAX*2) {
vector<lli> nuevo;
rep(i,0,MAX-1) nuevo.push_back(borr[act][i]);
nuevo.push_back(3);
rep(i,borr[act].size()-MAX,borr[act].size()-1) nuevo.push_back(borr[act][i]);
swap(nuevo, borr[act]);
}
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;break;}
}
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);
}
}
MAX = 0;
rep(i,1,m) {
cin >> a;
if (a > MAX) MAX = 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";
}
}
컴파일 시 표준 에러 (stderr) 메시지
Viruses.cpp: In function 'void DFS(int)':
Viruses.cpp:42:26: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if (borr[act].size() > MAX*2) {
| ~~~~~~~~~~~~~~~~~^~~~~~~
Viruses.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
Viruses.cpp:46:9: note: in expansion of macro 'rep'
46 | rep(i,borr[act].size()-MAX,borr[act].size()-1) nuevo.push_back(borr[act][i]);
| ^~~
Viruses.cpp:4:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
Viruses.cpp:53:9: note: in expansion of macro 'rep'
53 | 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<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
Viruses.cpp:55:13: note: in expansion of macro 'rep'
55 | rep(k,j,j+anti[i].size()-1) {
| ^~~
# | 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... |