답안 #973936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973936 2024-05-02T13:13:00 Z aeg Viruses (BOI20_viruses) C++14
0 / 100
1 ms 428 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int g, n, m;
vector<vector<vector<int>>> table;

vector<ll> dp;

inline ll f(int a, bitset<100> vis) {
	if(dp[a] != -1) return dp[a];
	vis[a] = true;
	ll ret = INT64_MAX;
	for(auto &x : table[a]) {
		ll cur = 0;
		for(auto &y : x) {
			if(vis[y]) {
				cur = -2;
				break;
			}
			cur += f(y, vis);
		}
		if(cur == -2) {
			continue;
		}
		ret = min(ret, cur);
	}
	dp[a] = ret;
	return dp[a];
}

int main() {
	cin >> g >> n >> m;

	table.resize(g);

	for(int i = 0; i < n; i ++) {
		int a, k;
		cin >> a >> k;
		table[a].push_back(vector<int>(k));
		for(int j = 0; j < k; j ++) {
			cin >> table[a].back()[j];
		}
	}

	for(int i = 0; i < m; i ++) {
		int k;
		cin >> k;
		for(int j = 0; j < k; j ++) {int tmp; cin >> tmp;}
	}

	dp.assign(g, -1);
	dp[0] = dp[1] = 1;
	for(int i = 0; i < g; i ++) {
		cout << f(i, bitset<100>(0)) << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 428 KB Output isn't correct
2 Halted 0 ms 0 KB -