Submission #516511

# Submission time Handle Problem Language Result Execution time Memory
516511 2022-01-21T12:40:23 Z blue Regions (IOI09_regions) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define sz(x) int(x.size())

const int maxN = 200'000;
const int maxR = 500;

int N, R, Q;
vi H(1+maxN), S(1+maxN);

vvl ans(1+maxR, vl(1+maxR, 0));

vl inc(1+maxR, 0);

void dfs(int u)
{
    for(int r = 1; r <= R; r++)
        ans[r][H[u]] += inc[r];


    inc[H[u]]++;

    for(int v: children[u])
    {
        dfs(v);
        subtree[u] += subtree[v];
    }

    inc[H[u]]--;
}







int main()
{
    // cout << "done\n";
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N >> R >> Q;

    cin >> H[1];
    S[1] = 0;

    for(int i = 2; i <= N; i++)
    {
        cin >> S[i] >> H[i];
        children[S[i]].push_back(i);
    }


    dfs(1);

    for(int q = 1; q <= Q; q++)
    {
        int r1, r2;
        cin >> r1 >> r2;

        cout << ans[r1][r2] << '\n';
        cout.flush();
    }

    return 0;


    // int r1, r2;
    // cin >> r1 >> r2;
    // cout << large_top[norm[r1]][r2] << '\n';
}

Compilation message

regions.cpp: In function 'void dfs(int)':
regions.cpp:31:16: error: 'children' was not declared in this scope
   31 |     for(int v: children[u])
      |                ^~~~~~~~
regions.cpp:34:9: error: 'subtree' was not declared in this scope
   34 |         subtree[u] += subtree[v];
      |         ^~~~~~~
regions.cpp: In function 'int main()':
regions.cpp:60:9: error: 'children' was not declared in this scope
   60 |         children[S[i]].push_back(i);
      |         ^~~~~~~~