Submission #600929

# Submission time Handle Problem Language Result Execution time Memory
600929 2022-07-21T09:16:15 Z Arnch Viruses (BOI20_viruses) C++17
11 / 100
2 ms 596 KB
// oooo
/*
 har chi delet mikhad bebar ~
 gitar o ba khodet nabar! ~
 ;Amoo_Hasan;
*/

#include<bits/stdc++.h>
//#pragma GCC optimize("O3,no-stack-protector,unroll-loops")
//#pragma GCC target("avx2,fma")

using namespace std;

typedef long long ll;
typedef long double ld;

#define Sz(x) int((x).size())
#define All(x) (x).begin(), (x).end()
#define wtf(x) cout<<#x <<" : " <<x <<endl

constexpr ll inf = 1e18, N = 1e3 + 10;

ll dp[N];
vector<int> vc[N], ind[N], val[N];

int main() {
    ios :: sync_with_stdio(0), cin.tie(0);
    
	int g, n, m; cin >>g >>n >>m;
	for(int i = 0; i < n; i++) {
		int a, k; cin >>a >>k;
		for(int j = 0; j < k; j++) {
			int u; cin >>u;
			val[i].push_back(u);
		}
		ind[a].push_back(i);
	}
	for(int i = 0; i < m; i++) {
		int s; cin >>s;
		for(int j = 0; j < s; j++) {
			int u; cin >>u;
			vc[i].push_back(u);
		}
	}

	assert(m == 0);

	for(int i = 0; i < g; i++) dp[i] = -1;
	dp[0] = dp[1] = 1;

	for(int t = 0; t < g; t++) {
		for(int i = 2; i < g; i++) {
			for(auto j : ind[i]) {
				ll cur = 0;
				bool flag = true;
				for(auto k : val[j]) {
					if(dp[k] == -1) {
						flag = false; break;
					}
					cur += dp[k];
				}
				if(flag) {
					if(dp[i] == -1) dp[i] = cur;
					else dp[i] = min(dp[i], cur);
				}
			}
		}
	}

	for(int i = 2; i < g; i++) {
		if(dp[i] == -1) cout<<"YES" <<endl;
		else cout<<"NO" <<" " <<dp[i] <<endl;
	}
	

	return 0;
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 1 ms 596 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 596 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Runtime error 2 ms 596 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 396 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 436 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 400 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 0 ms 340 KB Output is correct
19 Correct 0 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Runtime error 1 ms 596 KB Execution killed with signal 6
22 Halted 0 ms 0 KB -