# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
121191 | 2019-06-26T07:48:52 Z | 임유진(#2971) | Unique Cities (JOI19_ho_t5) | C++14 | 109 ms | 768 KB |
#include<stdio.h> #include<vector> using namespace std; #define MAXN 2005 vector<int> e[MAXN]; int A[MAXN], B[MAXN], C[MAXN]; int dep[MAXN]; int cntdep[MAXN]; bool chkc[MAXN]; void dfs(int x){ cntdep[dep[x]]++; for(auto a:e[x]) if(dep[a]==-1){ dep[a]=dep[x]+1; dfs(a); } } int main(){ int N, M; scanf("%d%d", &N, &M); for(int i=0; i<N-1; i++) scanf("%d%d", A+i, B+i); for(int i=1; i<=N; i++) scanf("%d", C+i); for(int i=0; i<N-1; i++){ e[A[i]].push_back(B[i]); e[B[i]].push_back(A[i]); } for(int i=1; i<=N; i++){ int ans=0; for(int j=1; j<=N; j++) dep[j]=-1; for(int j=0; j<N; j++) cntdep[j]=0; for(int j=1; j<=M; j++) chkc[j]=false; dep[i]=0; dfs(i); for(int j=1; j<=N; j++) if(i!=j&&cntdep[dep[j]]==1) chkc[C[j]]=true; for(int j=1; j<=M; j++) if(chkc[j]) ans++; printf("%d\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 69 ms | 512 KB | Output is correct |
3 | Correct | 20 ms | 512 KB | Output is correct |
4 | Correct | 73 ms | 512 KB | Output is correct |
5 | Correct | 80 ms | 512 KB | Output is correct |
6 | Correct | 99 ms | 512 KB | Output is correct |
7 | Correct | 88 ms | 512 KB | Output is correct |
8 | Correct | 75 ms | 512 KB | Output is correct |
9 | Correct | 89 ms | 512 KB | Output is correct |
10 | Correct | 101 ms | 512 KB | Output is correct |
11 | Correct | 88 ms | 632 KB | Output is correct |
12 | Correct | 38 ms | 512 KB | Output is correct |
13 | Correct | 99 ms | 512 KB | Output is correct |
14 | Correct | 87 ms | 464 KB | Output is correct |
15 | Correct | 84 ms | 528 KB | Output is correct |
16 | Correct | 31 ms | 512 KB | Output is correct |
17 | Correct | 86 ms | 512 KB | Output is correct |
18 | Correct | 77 ms | 512 KB | Output is correct |
19 | Correct | 86 ms | 512 KB | Output is correct |
20 | Correct | 103 ms | 512 KB | Output is correct |
21 | Correct | 83 ms | 552 KB | Output is correct |
22 | Correct | 83 ms | 548 KB | Output is correct |
23 | Correct | 93 ms | 512 KB | Output is correct |
24 | Correct | 87 ms | 512 KB | Output is correct |
25 | Correct | 89 ms | 512 KB | Output is correct |
26 | Correct | 40 ms | 512 KB | Output is correct |
27 | Correct | 109 ms | 572 KB | Output is correct |
28 | Correct | 84 ms | 632 KB | Output is correct |
29 | Correct | 80 ms | 536 KB | Output is correct |
30 | Correct | 32 ms | 512 KB | Output is correct |
31 | Correct | 75 ms | 512 KB | Output is correct |
32 | Correct | 72 ms | 512 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 768 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5 ms | 768 KB | Time limit exceeded (wall clock) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 69 ms | 512 KB | Output is correct |
3 | Correct | 20 ms | 512 KB | Output is correct |
4 | Correct | 73 ms | 512 KB | Output is correct |
5 | Correct | 80 ms | 512 KB | Output is correct |
6 | Correct | 99 ms | 512 KB | Output is correct |
7 | Correct | 88 ms | 512 KB | Output is correct |
8 | Correct | 75 ms | 512 KB | Output is correct |
9 | Correct | 89 ms | 512 KB | Output is correct |
10 | Correct | 101 ms | 512 KB | Output is correct |
11 | Correct | 88 ms | 632 KB | Output is correct |
12 | Correct | 38 ms | 512 KB | Output is correct |
13 | Correct | 99 ms | 512 KB | Output is correct |
14 | Correct | 87 ms | 464 KB | Output is correct |
15 | Correct | 84 ms | 528 KB | Output is correct |
16 | Correct | 31 ms | 512 KB | Output is correct |
17 | Correct | 86 ms | 512 KB | Output is correct |
18 | Correct | 77 ms | 512 KB | Output is correct |
19 | Correct | 86 ms | 512 KB | Output is correct |
20 | Correct | 103 ms | 512 KB | Output is correct |
21 | Correct | 83 ms | 552 KB | Output is correct |
22 | Correct | 83 ms | 548 KB | Output is correct |
23 | Correct | 93 ms | 512 KB | Output is correct |
24 | Correct | 87 ms | 512 KB | Output is correct |
25 | Correct | 89 ms | 512 KB | Output is correct |
26 | Correct | 40 ms | 512 KB | Output is correct |
27 | Correct | 109 ms | 572 KB | Output is correct |
28 | Correct | 84 ms | 632 KB | Output is correct |
29 | Correct | 80 ms | 536 KB | Output is correct |
30 | Correct | 32 ms | 512 KB | Output is correct |
31 | Correct | 75 ms | 512 KB | Output is correct |
32 | Correct | 72 ms | 512 KB | Output is correct |
33 | Execution timed out | 5 ms | 768 KB | Time limit exceeded (wall clock) |
34 | Halted | 0 ms | 0 KB | - |