답안 #953522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
953522 2024-03-26T05:08:13 Z koukirocks Viruses (BOI20_viruses) C++17
0 / 100
0 ms 600 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
 
namespace{using namespace std;}
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=100+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
const ldb eps=1e-6;

int g,n,m;
vector<vector<int> > GT[MAX];

int main() {
	speed;
	cin>>g>>n>>m;
	for (int i=0;i<n;i++) {
		int a,k;
		vector<int> mut;
		cin>>a>>k;
		while (k--) {
			int x;
			cin>>x;
			mut.push_back(x);
		}
		GT[a].push_back(mut);
	}
	int ans[MAX];
	memset(ans,-1,sizeof(ans));
	ans[0]=1;
	ans[1]=1;
	int cnt=g-2;
	for (int _=2;cnt and _<g;_++) {
		for (int i=2;i<g;i++) {
			if (ans[i]!=-1) continue;
			for (auto st:GT[i]) {
				for (int k:st) {
					if (ans[k]==-1) {
						goto skip;
					}
				}
			}
			ans[i]=INF;
			for (auto st:GT[i]) {
				int ttl=0;
				for (int k:st) {
					ttl+=ans[k];
				}
				ans[i]=min(ans[i],ttl);
			}
			cnt--;
			skip:;
		}
	}
	for (int i=0;i<g;i++) {
		cout<<"NO "<<ans[i]<<"\n";
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -