# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
321323 | 2020-11-12T05:52:05 Z | ronnith | Regions (IOI09_regions) | C++14 | 1740 ms | 26980 KB |
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i = a;i < b;i ++) #define trav(e,x) for(auto e:x) #define maxn 200000 #define maxr 500 using namespace std; int N, R, Q, region[maxn], ans[maxr][maxr]; vector<int> adj[maxn]; void dfs(int x,int pr,int crr,int val) { if(region[x] == crr)val ++; ans[crr][region[x]] += val; trav(e,adj[x]) { if(e != pr) { dfs(e,x,crr,val); } } } void preProccess() { FOR(i,0,R) { dfs(0,-1,i,0); } } int main() { scanf("%d%d%d",&N,&R,&Q); int x,y; scanf("%d",&x); region[0] = x - 1; FOR(i,0,N - 1) { scanf("%d%d",&x,&y); x --;y --; adj[i + 1].push_back(x); adj[x].push_back(i + 1); region[i + 1] = y; } FOR(i,0,R) { fill(ans[i],ans[i] + R,0); } preProccess(); FOR(i,0,Q) { scanf("%d%d",&x,&y); x --;y --; printf("%d\n", ans[x][y]); fflush(stdout); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 4972 KB | Output is correct |
2 | Correct | 3 ms | 5100 KB | Output is correct |
3 | Correct | 5 ms | 5100 KB | Output is correct |
4 | Correct | 7 ms | 5100 KB | Output is correct |
5 | Correct | 11 ms | 5100 KB | Output is correct |
6 | Correct | 23 ms | 5612 KB | Output is correct |
7 | Correct | 25 ms | 5376 KB | Output is correct |
8 | Correct | 39 ms | 5484 KB | Output is correct |
9 | Correct | 67 ms | 6124 KB | Output is correct |
10 | Correct | 161 ms | 6400 KB | Output is correct |
11 | Correct | 183 ms | 6124 KB | Output is correct |
12 | Correct | 224 ms | 6892 KB | Output is correct |
13 | Correct | 365 ms | 6628 KB | Output is correct |
14 | Correct | 330 ms | 6508 KB | Output is correct |
15 | Correct | 295 ms | 9452 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 954 ms | 9032 KB | Output is correct |
2 | Correct | 1627 ms | 8548 KB | Output is correct |
3 | Correct | 1740 ms | 10980 KB | Output is correct |
4 | Runtime error | 24 ms | 15488 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
5 | Runtime error | 28 ms | 15844 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
6 | Runtime error | 34 ms | 16868 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
7 | Runtime error | 40 ms | 18020 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
8 | Runtime error | 51 ms | 19900 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
9 | Runtime error | 73 ms | 23140 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
10 | Runtime error | 86 ms | 24292 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
11 | Runtime error | 96 ms | 26980 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
12 | Runtime error | 91 ms | 25572 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
13 | Runtime error | 88 ms | 25572 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
14 | Runtime error | 92 ms | 26212 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
15 | Runtime error | 94 ms | 26340 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
16 | Runtime error | 97 ms | 26212 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Runtime error | 93 ms | 26212 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |