답안 #974021

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974021 2024-05-02T15:20:39 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++){
		cout << "NO " << f(i) << '\n';
	}
}
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 Incorrect 2 ms 5724 KB Output isn't correct
2 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 Incorrect 1 ms 5720 KB Output isn't correct
2 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 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -