Submission #1292078

#TimeUsernameProblemLanguageResultExecution timeMemory
1292078qrnRegions (IOI09_regions)C++20
8 / 100
354 ms196608 KiB
// ome47 // booooooo #include "bits/stdc++.h" using namespace std; #define intt long long const intt mxN = 2e5 + 5; const intt LG = 20; const intt inf = 1e18; intt n, r, q; vector<vector<intt>> graph, boo; vector<intt> h(mxN), par(mxN); set<intt> st[mxN]; void dfs(intt node, intt parent) { st[node].insert(node); for(auto u : graph[node]) { if(u != parent) { dfs(u, node); for(auto p : st[u]) st[node].insert(p); } } } void _() { cin >> n >> r >> q; graph.assign(n + 1, vector<intt> {}); boo.assign(r + 1, vector<intt>(r + 1, 0ll)); for(intt i = 1; i <= n; i++) { intt supervisor, race; if(i == 1) { cin >> race; } else { cin >> supervisor >> race; graph[supervisor].push_back(i); graph[i].push_back(supervisor); } h[i] = race; } dfs(1, 1); for(intt i = 1; i <= n; i++) { for(auto p : st[i]) { boo[h[i]][h[p]]++; } } // cout << "ASDSAD" << endl; // for(intt i = 1; i <= r; i++) { // for(intt j = 1; j <= r; j++) { // cout << boo[i][j] << " "; // } // cout << endl; // } while(q--) { intt a, b; cin >> a >> b; cout << boo[a][b] << "\n"; cout.flush(); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); intt t = 1; // cin >> t; while(t--){ // cout << endl; _(); } } // ⠀⠀⠀⠀⠀⠀⠀⢀⣤⣦⣶⣤⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ // ⣤⢀⣀⡀⣠⣄⣠⣶⣿⣿⣿⣿⣿⣿⣿⣷⣾⡦⠀⠀⠀⠀⠀⠀⠀⠀⠀ // ⠻⡳⢛⠛⠒⠚⢛⣿⣿⠟⠋⠉⠛⠛⢿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀ // ⢛⡛⢿⣿⠟⠻⠛⣿⣇⣶⣖⣤⣀⣄⡰⣹⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀ // ⢿⠿⠿⠿⠿⠿⠿⢭⣐⠠⢼⣬⠽⢈⢁⡿⠛⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀ // ⣛⣱⣤⣤⣤⣀⣄⣄⣗⢌⠋⠉⢙⣴⣧⢤⣤⣤⣤⣦⡀⠀⠀⠀⠀⢺⡿ // ⣿⣿⣿⠟⠛⠋⠀⡬⠼⢠⠍⠂⠀⠨⡇⠀⡏⠉⠛⢿⣧⠀⠀⠀⠀⢸⣀ // ⣟⠄⠀⠀⠀⠀⠀⢡⠀⠀⠀⠀⠀⡠⠁⢀⠁⠀⠀⠀⠘⣗⢀⠄⢶⣼⣾ // ⠀⠀⠀⢠⣦⠇⠀⠀⠁⠒⠒⠒⠈⠀⠀⠀⣞⢶⡀⠀⠀⠹⣧⣠⡞⣸⣏ // ⠀⠀⢀⡞⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣦⡀⠀⠈⠫⣕⣻⡇ // ⠀⠀⣾⣧⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⣿⣿⣿⣷⣦⡠⡤⠀⣿⡇ // ⠠⢿⣿⣿⠂⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠀⠴⣿⣿⣿⣿⠟⠋⢀⣤⣿⣷ // ⣀⣀⣀⣙⣃⣠⣤⣔⣤⣢⣵⣒⣒⣢⣄⣤⣄⣛⣋⣉⣀⣀⣤⣿⣿⣿⣿
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...