# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
933030 | 2024-02-24T22:06:48 Z | vjudge1 | Regions (IOI09_regions) | C++ | 146 ms | 20936 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int n, r, q; int papa[200000]; int reg[200000]; vector<vector<int>> adj; int busca(int node, int &r2){ int cnt=0; if(reg[node]==r2) cnt++; for(int i=0; i<adj[node].size(); i++){ cnt+=busca(adj[node][i], r2); } return cnt; } void checa(int r1, int r2){ int ans=0; for(int i=0; i<n; i++){ if(reg[i]==r1){ ans+=busca(i, r2); } if(r1==r2) ans--; } cout<< ans; fflush(stdout); } void solve(){ int x; cin>> n>> r>> q; adj.resize(n); cin>> reg[0]; for(int i=1; i<n; i++){ cin>> papa[i]>> reg[i]; papa[i]--; adj[papa[i]].push_back(i); //adj[i].push_back(papa[i]); } int r1, r2; for(int i=0; i<q; i++){ cin>> r1>> r2; checa(r1, r2); } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int t=1; //cin>> t; while(t--){ solve(); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
2 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
3 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
4 | Execution timed out | 0 ms | 344 KB | Time limit exceeded (wall clock) |
5 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
6 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
7 | Execution timed out | 1 ms | 340 KB | Time limit exceeded (wall clock) |
8 | Execution timed out | 1 ms | 344 KB | Time limit exceeded (wall clock) |
9 | Execution timed out | 2 ms | 856 KB | Time limit exceeded (wall clock) |
10 | Execution timed out | 2 ms | 856 KB | Time limit exceeded (wall clock) |
11 | Execution timed out | 3 ms | 1276 KB | Time limit exceeded (wall clock) |
12 | Execution timed out | 7 ms | 1880 KB | Time limit exceeded (wall clock) |
13 | Execution timed out | 5 ms | 1568 KB | Time limit exceeded (wall clock) |
14 | Execution timed out | 6 ms | 2012 KB | Time limit exceeded (wall clock) |
15 | Execution timed out | 24 ms | 4696 KB | Time limit exceeded (wall clock) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 59 ms | 5720 KB | Time limit exceeded (wall clock) |
2 | Execution timed out | 17 ms | 4436 KB | Time limit exceeded (wall clock) |
3 | Execution timed out | 41 ms | 7524 KB | Time limit exceeded (wall clock) |
4 | Execution timed out | 6 ms | 2164 KB | Time limit exceeded (wall clock) |
5 | Execution timed out | 10 ms | 3928 KB | Time limit exceeded (wall clock) |
6 | Execution timed out | 37 ms | 3572 KB | Time limit exceeded (wall clock) |
7 | Execution timed out | 28 ms | 4504 KB | Time limit exceeded (wall clock) |
8 | Execution timed out | 33 ms | 9784 KB | Time limit exceeded (wall clock) |
9 | Execution timed out | 71 ms | 10296 KB | Time limit exceeded (wall clock) |
10 | Execution timed out | 79 ms | 15372 KB | Time limit exceeded (wall clock) |
11 | Execution timed out | 44 ms | 10196 KB | Time limit exceeded (wall clock) |
12 | Execution timed out | 32 ms | 12132 KB | Time limit exceeded (wall clock) |
13 | Execution timed out | 31 ms | 12088 KB | Time limit exceeded (wall clock) |
14 | Execution timed out | 51 ms | 11900 KB | Time limit exceeded (wall clock) |
15 | Execution timed out | 103 ms | 16080 KB | Time limit exceeded (wall clock) |
16 | Execution timed out | 47 ms | 20936 KB | Time limit exceeded (wall clock) |
17 | Execution timed out | 146 ms | 20776 KB | Time limit exceeded (wall clock) |