Submission #1174523

#TimeUsernameProblemLanguageResultExecution timeMemory
1174523nuutsnoyntonUzastopni (COCI15_uzastopni)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;
using ll = int
const ll N = 1e4 + 2;
ll dp[N][104][104];
ll c[N];
vector < ll > adj[N];

void Go(ll node, ll par) {
	ll j, r, sz, pd[102][102] ={0};
	for ( ll chi : adj[node]) {
		if ( chi == par) continue;
		Go(chi, node);
		for ( j= 1; j <= 100; j ++) {
			for ( r = j; r <= 100; r ++) {
				pd[j][r] += dp[chi][j][r];
			}
		}
	}
	for ( sz = 1; sz <= 100; sz ++) {
		for ( j = 1; j <= 100; j ++) {
			for ( r = 1;  r< sz; r ++) {
				if ( j + sz - 1 > 100) continue;
				pd[j][j + sz  - 1] = pd[j][j + sz - 1] + (pd[j][j + r - 1] * pd[j + r][j + sz - 1]);
			}
		}
	}
	ll p = c[node];
	for ( j= p; j >= 1; j --) {
		for ( r = p; r <= 100; r ++) {
			if(  r== p && j == p) {
				dp[node][j][r] = 1;
				continue;
			}
			if ( r == p) {
				dp[node][j][r] = pd[j][p - 1];
				continue;
			}
			if ( j == p) {
				dp[node][j][r] = pd[p + 1][r];
				continue;
			}
			
			dp[node][j][r] =dp[node][j][r] +  pd[j][p - 1] * pd[p + 1][r];
		}
	}
}

int main() {
	ll n, m, r, x, y, i, j, ans, t;
	
	cin >> n;
	for (i = 1; i <= n; i++) {
		cin >> c[i];
	}
	
	for (i = 1; i < n; i ++) {
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}	
	
	Go(1, 1);
	ans = 0;
	for (i = 1; i<= 100; i ++){
		for (j = i; j <= 100; j ++) {
			ans += dp[1][i][j];
		}
	}
	cout << ans << endl;


}

Compilation message (stderr)

uzastopni.cpp:5:6: error: expected ';' before 'll'
    5 | const ll N = 1e4 + 2;
      |      ^~~
      |      ;
uzastopni.cpp:6:1: error: 'll' does not name a type
    6 | ll dp[N][104][104];
      | ^~
uzastopni.cpp:7:1: error: 'll' does not name a type
    7 | ll c[N];
      | ^~
uzastopni.cpp:8:10: error: 'll' was not declared in this scope
    8 | vector < ll > adj[N];
      |          ^~
uzastopni.cpp:8:13: error: template argument 1 is invalid
    8 | vector < ll > adj[N];
      |             ^
uzastopni.cpp:8:13: error: template argument 2 is invalid
uzastopni.cpp:8:19: error: 'N' was not declared in this scope
    8 | vector < ll > adj[N];
      |                   ^
uzastopni.cpp:10:6: error: variable or field 'Go' declared void
   10 | void Go(ll node, ll par) {
      |      ^~
uzastopni.cpp:10:9: error: 'll' was not declared in this scope
   10 | void Go(ll node, ll par) {
      |         ^~
uzastopni.cpp:10:18: error: 'll' was not declared in this scope
   10 | void Go(ll node, ll par) {
      |                  ^~
uzastopni.cpp: In function 'int main()':
uzastopni.cpp:51:9: error: 'll' was not declared in this scope
   51 |         ll n, m, r, x, y, i, j, ans, t;
      |         ^~
uzastopni.cpp:53:16: error: 'n' was not declared in this scope; did you mean 'yn'?
   53 |         cin >> n;
      |                ^
      |                yn
uzastopni.cpp:54:14: error: 'i' was not declared in this scope
   54 |         for (i = 1; i <= n; i++) {
      |              ^
uzastopni.cpp:55:24: error: 'c' was not declared in this scope
   55 |                 cin >> c[i];
      |                        ^
uzastopni.cpp:58:14: error: 'i' was not declared in this scope
   58 |         for (i = 1; i < n; i ++) {
      |              ^
uzastopni.cpp:59:24: error: 'x' was not declared in this scope
   59 |                 cin >> x >> y;
      |                        ^
uzastopni.cpp:59:29: error: 'y' was not declared in this scope; did you mean 'yn'?
   59 |                 cin >> x >> y;
      |                             ^
      |                             yn
uzastopni.cpp:60:17: error: 'adj' was not declared in this scope
   60 |                 adj[x].push_back(y);
      |                 ^~~
uzastopni.cpp:64:9: error: 'Go' was not declared in this scope
   64 |         Go(1, 1);
      |         ^~
uzastopni.cpp:65:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   65 |         ans = 0;
      |         ^~~
      |         abs
uzastopni.cpp:66:14: error: 'i' was not declared in this scope
   66 |         for (i = 1; i<= 100; i ++){
      |              ^
uzastopni.cpp:67:22: error: 'j' was not declared in this scope; did you mean 'jn'?
   67 |                 for (j = i; j <= 100; j ++) {
      |                      ^
      |                      jn
uzastopni.cpp:68:32: error: 'dp' was not declared in this scope; did you mean 'dup'?
   68 |                         ans += dp[1][i][j];
      |                                ^~
      |                                dup