Submission #649616

# Submission time Handle Problem Language Result Execution time Memory
649616 2022-10-11T06:28:21 Z mychecksedad Regions (IOI09_regions) C++17
0 / 100
690 ms 131072 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;


int n, q, r, a[N], ans[505][505];
vector<int> g[N], R[N];

void dfs(int v, int p){
    R[v].resize(r + 1);
    for(int u: g[v]){
        if(u == p) continue;
        dfs(u, v);
        for(int j = 1; j <= r; ++j) R[v][j] += R[u][j];
    }
    for(int j = 1; j <= r; ++j) ans[a[v]][j] += R[v][j];
    R[v][a[v]]++;    
}

void solve(){
    cin >> n >> r >> q;
    cin >> a[1];
    for(int i = 2; i <= n; ++i){
        int x; cin >> x >> a[i];
        g[x].pb(i);
        g[i].pb(x);
    }
    for(int i = 0; i <= r; ++i) for(int j = 0; j <= r; ++j) ans[i][j] = 0;
    dfs(1, 1);
    for(;q--;){
        int a, b; cin >> a >> b;
        cout << ans[a][b] << endl;
    }
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

regions.cpp: In function 'int main()':
regions.cpp:54:16: warning: unused variable 'aa' [-Wunused-variable]
   54 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Runtime error 22 ms 47256 KB Execution killed with signal 13
2 Runtime error 21 ms 47304 KB Execution killed with signal 13
3 Runtime error 23 ms 47312 KB Execution killed with signal 13
4 Runtime error 27 ms 47432 KB Execution killed with signal 13
5 Runtime error 29 ms 47472 KB Execution killed with signal 13
6 Runtime error 38 ms 48592 KB Execution killed with signal 13
7 Runtime error 48 ms 48556 KB Execution killed with signal 13
8 Runtime error 49 ms 49384 KB Execution killed with signal 13
9 Runtime error 70 ms 54400 KB Execution killed with signal 13
10 Runtime error 70 ms 65168 KB Execution killed with signal 13
11 Runtime error 114 ms 64592 KB Execution killed with signal 13
12 Runtime error 173 ms 84836 KB Execution killed with signal 13
13 Runtime error 174 ms 81188 KB Execution killed with signal 13
14 Runtime error 194 ms 72612 KB Execution killed with signal 13
15 Runtime error 211 ms 90568 KB Execution killed with signal 13
# Verdict Execution time Memory Grader output
1 Runtime error 632 ms 111372 KB Execution killed with signal 13
2 Runtime error 690 ms 120924 KB Execution killed with signal 13
3 Runtime error 110 ms 131072 KB Execution killed with signal 9
4 Runtime error 73 ms 107476 KB Execution killed with signal 11
5 Runtime error 77 ms 107960 KB Execution killed with signal 11
6 Runtime error 82 ms 108956 KB Execution killed with signal 11
7 Runtime error 95 ms 110044 KB Execution killed with signal 11
8 Runtime error 93 ms 111940 KB Execution killed with signal 11
9 Runtime error 108 ms 115132 KB Execution killed with signal 11
10 Runtime error 114 ms 116412 KB Execution killed with signal 11
11 Runtime error 122 ms 118876 KB Execution killed with signal 11
12 Runtime error 129 ms 117596 KB Execution killed with signal 11
13 Runtime error 121 ms 117668 KB Execution killed with signal 11
14 Runtime error 130 ms 118468 KB Execution killed with signal 11
15 Runtime error 124 ms 118312 KB Execution killed with signal 11
16 Runtime error 124 ms 118256 KB Execution killed with signal 11
17 Runtime error 129 ms 118296 KB Execution killed with signal 11