# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
397850 | 2021-05-03T09:38:17 Z | maomao90 | Hotspot (NOI17_hotspot) | C++14 | 812 ms | 1192 KB |
#include <bits/stdc++.h> using namespace std; #define INF 1000000000 int n, m, k; vector <int> adjList[5005]; int dist[5005], dist1[5005], times[5005], times1[5005]; queue <int> bfs; double e[5005]; int ans = -1; int main() { scanf("%d%d", &n, &m); for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); adjList[u].push_back(v); adjList[v].push_back(u); } scanf("%d", &k); for (int i = 0; i < k; i++) { int a, b; scanf("%d%d", &a, &b); for (int j = 0; j < n; j++) dist[j] = INF, times[j] = 0; dist[a] = 0, times[a] = 1; bfs.push(a); while (!bfs.empty()) { int u = bfs.front(); bfs.pop(); for (int v : adjList[u]) { if (dist[v] > dist[u] + 1) { dist[v] = dist[u] + 1; times[v] = times[u]; bfs.push(v); } else if (dist[v] == dist[u] + 1) { times[v] += times[u]; } } } int nosp = times[b], sp = dist[b]; for (int j = 0; j < n; j++) dist1[j] = INF, times1[j] = 0; dist1[b] = 0, times1[b] = 1; bfs.push(b); while (!bfs.empty()) { int u = bfs.front(); bfs.pop(); for (int v : adjList[u]) { if (dist1[v] > dist1[u] + 1) { dist1[v] = dist1[u] + 1; times1[v] = times1[u]; bfs.push(v); } else if (dist1[v] == dist1[u] + 1) { times1[v] += times1[u]; } } } for (int u = 0; u < n; u++) { if (dist[u] + dist1[u] == sp) { e[u] += (double) (times[u] * times1[u]) / nosp; //printf("%d: %f\n", u, e[u]); } } } double curmax = -1; for (int i = 0; i < n; i++) { if (e[i] > curmax) curmax = e[i], ans = i; } printf("%d\n", ans); return 0; } /* 15 19 0 3 1 3 1 4 1 5 2 5 3 6 3 7 4 7 5 7 6 10 7 9 7 10 7 11 8 11 9 12 9 13 10 13 11 13 11 14 2 4 10 3 8 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 460 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 428 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 420 KB | Output is correct |
14 | Correct | 1 ms | 436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 2 ms | 460 KB | Output is correct |
10 | Correct | 2 ms | 460 KB | Output is correct |
11 | Correct | 3 ms | 460 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 332 KB | Output is correct |
14 | Correct | 2 ms | 460 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 460 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 428 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 420 KB | Output is correct |
14 | Correct | 1 ms | 436 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 2 ms | 460 KB | Output is correct |
17 | Correct | 2 ms | 460 KB | Output is correct |
18 | Correct | 3 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 2 ms | 460 KB | Output is correct |
22 | Correct | 2 ms | 464 KB | Output is correct |
23 | Correct | 2 ms | 460 KB | Output is correct |
24 | Correct | 3 ms | 460 KB | Output is correct |
25 | Correct | 4 ms | 460 KB | Output is correct |
26 | Correct | 4 ms | 460 KB | Output is correct |
27 | Correct | 1 ms | 436 KB | Output is correct |
28 | Correct | 3 ms | 436 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 460 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 428 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 420 KB | Output is correct |
14 | Correct | 1 ms | 436 KB | Output is correct |
15 | Correct | 3 ms | 588 KB | Output is correct |
16 | Correct | 2 ms | 460 KB | Output is correct |
17 | Correct | 7 ms | 636 KB | Output is correct |
18 | Correct | 3 ms | 460 KB | Output is correct |
19 | Correct | 5 ms | 588 KB | Output is correct |
20 | Correct | 4 ms | 532 KB | Output is correct |
21 | Correct | 1 ms | 440 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 460 KB | Output is correct |
2 | Correct | 1 ms | 460 KB | Output is correct |
3 | Correct | 1 ms | 460 KB | Output is correct |
4 | Correct | 1 ms | 332 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 460 KB | Output is correct |
7 | Correct | 1 ms | 460 KB | Output is correct |
8 | Correct | 1 ms | 460 KB | Output is correct |
9 | Correct | 1 ms | 460 KB | Output is correct |
10 | Correct | 1 ms | 460 KB | Output is correct |
11 | Correct | 1 ms | 428 KB | Output is correct |
12 | Correct | 1 ms | 332 KB | Output is correct |
13 | Correct | 1 ms | 420 KB | Output is correct |
14 | Correct | 1 ms | 436 KB | Output is correct |
15 | Correct | 1 ms | 460 KB | Output is correct |
16 | Correct | 2 ms | 460 KB | Output is correct |
17 | Correct | 2 ms | 460 KB | Output is correct |
18 | Correct | 3 ms | 460 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 2 ms | 460 KB | Output is correct |
22 | Correct | 2 ms | 464 KB | Output is correct |
23 | Correct | 2 ms | 460 KB | Output is correct |
24 | Correct | 3 ms | 460 KB | Output is correct |
25 | Correct | 4 ms | 460 KB | Output is correct |
26 | Correct | 4 ms | 460 KB | Output is correct |
27 | Correct | 1 ms | 436 KB | Output is correct |
28 | Correct | 3 ms | 436 KB | Output is correct |
29 | Correct | 3 ms | 588 KB | Output is correct |
30 | Correct | 2 ms | 460 KB | Output is correct |
31 | Correct | 7 ms | 636 KB | Output is correct |
32 | Correct | 3 ms | 460 KB | Output is correct |
33 | Correct | 5 ms | 588 KB | Output is correct |
34 | Correct | 4 ms | 532 KB | Output is correct |
35 | Correct | 1 ms | 440 KB | Output is correct |
36 | Correct | 64 ms | 672 KB | Output is correct |
37 | Correct | 148 ms | 732 KB | Output is correct |
38 | Correct | 812 ms | 1132 KB | Output is correct |
39 | Correct | 509 ms | 1144 KB | Output is correct |
40 | Correct | 84 ms | 836 KB | Output is correct |
41 | Correct | 478 ms | 1124 KB | Output is correct |
42 | Correct | 629 ms | 1192 KB | Output is correct |
43 | Correct | 38 ms | 588 KB | Output is correct |
44 | Correct | 38 ms | 588 KB | Output is correct |