제출 #1185638

#제출 시각아이디문제언어결과실행 시간메모리
1185638kl0989eViruses (BOI20_viruses)C++20
11 / 100
0 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	int g,n,m;
	cin >> g >> n >> m;
	vector<vector<vi>> ch(g);
	int a,sz;
	for (int i=0; i<n; i++) {
		cin >> a >> sz;
		ch[a].pb(vi(sz));
		for (int j=0; j<sz; j++) {
			cin >> ch[a].back()[j];
		}
	}
	vl sze(g,1e18);
	sze[0]=1;
	sze[1]=1;
	bool stop=0;
	while (!stop) {
		stop=1;
		for (int i=2; i<g; i++) {
			for (const auto& aa:ch[i]) {
				ll t=0;
				for (auto& a:aa) {
					t+=sze[a];
					t=min(t,(ll)1e18);
				}
				if (t<sze[i]) {
					sze[i]=t;
					stop=0;
				}
			}
		}
	}
	for (int i=2; i<g; i++) {
		if (sze[i]==1e18) {
			cout << "YES\n";
		}
		else {
			cout << "NO " << sze[i] << '\n';
		}
	}
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...