답안 #974014

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
974014 2024-05-02T15:12:41 Z NotLinux Viruses (BOI20_viruses) C++17
0 / 100
181 ms 262144 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];
vector < int > mutation[N+1] , bruh[N+1];
int f(int x){
	if(dp[x] != inf)return dp[x];
	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;
	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 Runtime error 181 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 181 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 5720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 181 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 181 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -