제출 #1328899

#제출 시각아이디문제언어결과실행 시간메모리
1328899paronmanukyanUzastopni (COCI15_uzastopni)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define uniq(x) x.resize(unique(all(x)) - x.begin());
#define sort_uniq(x) sort(all(x)), uniq(x);
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define V vector
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define INF INT32_MAX
#define blt __builtin_popcount
#define clr(x) x.clear()
#define ff first
#define ss second
#define popf pop_front
#define popb pop_back
#define sz(x) int(x.size())
#define rep(a, b, c, d) for (int a = b; a <= c; a += d)
#define repl(a, b, c, d) for (int a = b; a >= c; a -= d)

const int N = 1e4 + 1;
const int M = 101;

V<int> adj[N];
int v[N];
bitset<M> dp[N][M];
bitset<M> chld[M];

void dfs(int node) {
    dp[node][v[node]][v[node]] = 1;

    if (!sz(adj[node]))
        return;

    
    for (auto i : adj[node]) {
        dfs(i);
    }
	rep(i, 0, M - 1, 1)
        chld[i].reset();
	for (auto i : adj[node]) {
        dfs(i);
        chld[j] |= dp[i][j];
    }

    for (int i = M - 1; i >= 1; i--) {
        for (int j = i + 1; j < M; j++) {
            if (chld[i][j - 1])
                chld[i] |= chld[j];
        }
    }

    // node value
    rep(i, 1, v[node], 1) {
        rep(j, v[node], M - 1, 1) {
            if ((i == v[node] || chld[i][v[node] - 1]) &&
                (j == v[node] || chld[v[node] + 1][j]))
                dp[node][i][j] = 1;
        }
    }
}

int main() {
    FASTIO

    int n;
    cin >> n;

    rep(i, 1, n, 1)
        cin >> v[i];

    rep(i, 1, n - 1, 1) {
        int a, b;
        cin >> a >> b;
        adj[a].pb(b);
    }

    dfs(1);

    int ans = 0;
    rep(i, 1, M - 1, 1)
        ans += dp[1][i].count();

    cout << ans << "\n";
}

컴파일 시 표준 에러 (stderr) 메시지

uzastopni.cpp: In function 'void dfs(int)':
uzastopni.cpp:52:14: error: 'j' was not declared in this scope
   52 |         chld[j] |= dp[i][j];
      |              ^