답안 #974022

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974022 2024-05-02T15:21:23 Z NotLinux Viruses (BOI20_viruses) C++17
0 / 100
2 ms 5724 KB
//author : FatihCihan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
const int N = 1e5 + 7;
const int inf = 1e18 + 7;
int g,n,m,dp[N],vis[N];
vector < int > mutation[N+1] , bruh[N+1];
int f(int x){
	if(vis[x])return dp[x];
	vis[x] = 1;
	for(auto itr : bruh[x]){
		int local_ans = 0;
		for(auto itr1 : mutation[itr]){
			if(itr1 == x){
				local_ans = inf;
				break;
			}
			else{
				local_ans += f(itr1);
			}
		}
		dp[x] = min(dp[x] , local_ans);
	}
	return dp[x];
}
void solve(){
	for(int i = 0;i<N;i++)dp[i] = inf;

	cin >> g >> n >> m;
	for(int i = 0;i<n;i++){
		int a,k;
		cin >> a >> k;
		bruh[a].push_back(i);
		mutation[i].resize(k);
		for(int j = 0;j<k;j++){
			cin >> mutation[i][j];
		}
	}
	for(int i = 0;i<m;i++){
		int l;
		cin >> l;
		for(int j = 0;j<l;j++){
			int gh;
			cin >> gh;
		}
	}
	dp[0] = dp[1] = 1;
	vis[0] = vis[1] = 1;
	for(int i = 2;i<=g-1;i++){
		int res = f(i);
		if(res == inf)cout << "YES" << endl;
		else cout << "NO " << f(i) << endl;
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
	cerr << 1000.0 * clock() / CLOCKS_PER_SEC << " ms" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 2 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5720 KB Output is correct
7 Incorrect 2 ms 5724 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Incorrect 2 ms 5724 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 2 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5720 KB Output is correct
7 Incorrect 2 ms 5724 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5720 KB Output is correct
2 Correct 2 ms 5724 KB Output is correct
3 Correct 2 ms 5724 KB Output is correct
4 Correct 2 ms 5724 KB Output is correct
5 Correct 2 ms 5724 KB Output is correct
6 Correct 2 ms 5720 KB Output is correct
7 Incorrect 2 ms 5724 KB Output isn't correct
8 Halted 0 ms 0 KB -