# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
594222 | 2022-07-12T08:45:08 Z | 조영욱(#8434) | Unique Cities (JOI19_ho_t5) | C++17 | 257 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; int n,m; vector<int> adj[2000]; int c[2000]; int dist[2000]; int val[2000]; int main() { scanf("%d %d",&n,&m); for(int i=1;i<n;i++) { int u,v; scanf("%d %d",&u,&v); u--; v--; adj[u].push_back(v); adj[v].push_back(u); } for(int i=0;i<n;i++) { scanf("%d",&c[i]); } for(int i=0;i<n;i++) { queue<int> q; memset(dist,-1,sizeof(dist)); memset(val,0,sizeof(val)); q.push(i); dist[i]=0; while (!q.empty()) { int now=q.front(); q.pop(); for(int i=0;i<adj[now].size();i++) { int nt=adj[now][i]; if (dist[nt]==-1) { dist[nt]=dist[now]+1; q.push(nt); } } } for(int j=0;j<n;j++) { if (i==j) { continue; } if (val[dist[j]]==0) { val[dist[j]]=c[j]; } else { val[dist[j]]=-1; } } set<int> s; for(int i=0;i<n;i++) { if (val[i]>0) { s.insert(val[i]); } } printf("%d\n",s.size()); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 87 ms | 408 KB | Output is correct |
3 | Correct | 58 ms | 412 KB | Output is correct |
4 | Correct | 101 ms | 424 KB | Output is correct |
5 | Correct | 104 ms | 340 KB | Output is correct |
6 | Correct | 137 ms | 416 KB | Output is correct |
7 | Correct | 109 ms | 420 KB | Output is correct |
8 | Correct | 96 ms | 420 KB | Output is correct |
9 | Correct | 112 ms | 432 KB | Output is correct |
10 | Correct | 101 ms | 416 KB | Output is correct |
11 | Correct | 107 ms | 420 KB | Output is correct |
12 | Correct | 62 ms | 436 KB | Output is correct |
13 | Correct | 132 ms | 420 KB | Output is correct |
14 | Correct | 108 ms | 340 KB | Output is correct |
15 | Correct | 110 ms | 416 KB | Output is correct |
16 | Correct | 51 ms | 428 KB | Output is correct |
17 | Correct | 101 ms | 420 KB | Output is correct |
18 | Correct | 97 ms | 420 KB | Output is correct |
19 | Correct | 101 ms | 416 KB | Output is correct |
20 | Correct | 257 ms | 468 KB | Output is correct |
21 | Correct | 123 ms | 340 KB | Output is correct |
22 | Correct | 91 ms | 416 KB | Output is correct |
23 | Correct | 107 ms | 412 KB | Output is correct |
24 | Correct | 100 ms | 340 KB | Output is correct |
25 | Correct | 104 ms | 420 KB | Output is correct |
26 | Correct | 60 ms | 432 KB | Output is correct |
27 | Correct | 205 ms | 468 KB | Output is correct |
28 | Correct | 157 ms | 468 KB | Output is correct |
29 | Correct | 117 ms | 440 KB | Output is correct |
30 | Correct | 51 ms | 340 KB | Output is correct |
31 | Correct | 133 ms | 444 KB | Output is correct |
32 | Correct | 111 ms | 444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 87 ms | 408 KB | Output is correct |
3 | Correct | 58 ms | 412 KB | Output is correct |
4 | Correct | 101 ms | 424 KB | Output is correct |
5 | Correct | 104 ms | 340 KB | Output is correct |
6 | Correct | 137 ms | 416 KB | Output is correct |
7 | Correct | 109 ms | 420 KB | Output is correct |
8 | Correct | 96 ms | 420 KB | Output is correct |
9 | Correct | 112 ms | 432 KB | Output is correct |
10 | Correct | 101 ms | 416 KB | Output is correct |
11 | Correct | 107 ms | 420 KB | Output is correct |
12 | Correct | 62 ms | 436 KB | Output is correct |
13 | Correct | 132 ms | 420 KB | Output is correct |
14 | Correct | 108 ms | 340 KB | Output is correct |
15 | Correct | 110 ms | 416 KB | Output is correct |
16 | Correct | 51 ms | 428 KB | Output is correct |
17 | Correct | 101 ms | 420 KB | Output is correct |
18 | Correct | 97 ms | 420 KB | Output is correct |
19 | Correct | 101 ms | 416 KB | Output is correct |
20 | Correct | 257 ms | 468 KB | Output is correct |
21 | Correct | 123 ms | 340 KB | Output is correct |
22 | Correct | 91 ms | 416 KB | Output is correct |
23 | Correct | 107 ms | 412 KB | Output is correct |
24 | Correct | 100 ms | 340 KB | Output is correct |
25 | Correct | 104 ms | 420 KB | Output is correct |
26 | Correct | 60 ms | 432 KB | Output is correct |
27 | Correct | 205 ms | 468 KB | Output is correct |
28 | Correct | 157 ms | 468 KB | Output is correct |
29 | Correct | 117 ms | 440 KB | Output is correct |
30 | Correct | 51 ms | 340 KB | Output is correct |
31 | Correct | 133 ms | 444 KB | Output is correct |
32 | Correct | 111 ms | 444 KB | Output is correct |
33 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |