Submission #494922

# Submission time Handle Problem Language Result Execution time Memory
494922 2021-12-17T13:57:35 Z YJU Magic Tree (CEOI19_magictree) C++14
6 / 100
536 ms 8288 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops, no-stack-protector, Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
const ll INF = (1LL<<60);
const ll N = 1e3 + 5;
const ll MOD = 1e9 + 7;
const ld pi = acos(-1);
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
#define setp setprecision

ll dp[N][N], d[N], w[N], n, m, t;
vector<ll> v[N];

void DFS(ll now) {
	for (ll to : v[now]) {
		DFS(to);
	}
	for (ll j = 0;j <= t; ++j) {
		dp[now][j] = (j == d[now] ? w[now] : 0);
		for (ll to : v[now]) {
			ll ma = 0;
			for (ll k = 0;k <= j; ++k) {
				ma = max(ma, dp[to][k]);
			}
			dp[now][j] += ma;
		}
	}
}


int main () {
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> t;
	for (ll i = 2, x;i <= n; ++i) {
		cin >> x;
		v[x].pb(i);
	}
	for (ll i = 0, x;i < m; ++i) {
		cin >> x;
		cin >> d[x] >> w[x];
	}
	DFS(1);
	cout << dp[1][t] << "\n";
	return 0;
}

Compilation message

magictree.cpp:2:63: warning: bad option '-f no-stack-protector' to pragma 'optimize' [-Wpragmas]
    2 | #pragma GCC optimize("unroll-loops, no-stack-protector, Ofast")
      |                                                               ^
magictree.cpp:2:63: warning: bad option '-f Ofast' to pragma 'optimize' [-Wpragmas]
magictree.cpp:22:16: warning: bad option '-f no-stack-protector' to attribute 'optimize' [-Wattributes]
   22 | void DFS(ll now) {
      |                ^
magictree.cpp:22:16: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
magictree.cpp:39:11: warning: bad option '-f no-stack-protector' to attribute 'optimize' [-Wattributes]
   39 | int main () {
      |           ^
magictree.cpp:39:11: warning: bad option '-f Ofast' to attribute 'optimize' [-Wattributes]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 624 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 536 ms 8268 KB Output is correct
2 Correct 523 ms 8288 KB Output is correct
3 Correct 522 ms 8268 KB Output is correct
4 Runtime error 1 ms 592 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Runtime error 1 ms 872 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 616 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Correct 536 ms 8268 KB Output is correct
11 Correct 523 ms 8288 KB Output is correct
12 Correct 522 ms 8268 KB Output is correct
13 Runtime error 1 ms 592 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 0 ms 336 KB Output is correct
10 Runtime error 1 ms 624 KB Execution killed with signal 11
11 Halted 0 ms 0 KB -