# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1102944 |
2024-10-19T09:11:02 Z |
icebear |
Hotspot (NOI17_hotspot) |
C++17 |
|
626 ms |
186828 KB |
// ~~ icebear & at~~
#include <bits/stdc++.h>
using namespace std;
#define int long long
const double eps = 1e-6;
const int N = 5000 + 5;
int numNode, numEdge, numQuery;
vector<int> G[N];
int dist[N][N], ways[N][N];
bool computed[N];
queue<int> Q;
int a[N], b[N];
void BFS(int x) {
memset(dist[x], 0x3f, sizeof dist[x]);
dist[x][x] = 0;
ways[x][x] = 1;
Q.push(x);
while(!Q.empty()) {
int u = Q.front(); Q.pop();
for (int v : G[u])
if (dist[x][v] > dist[x][u] + 1) {
dist[x][v] = dist[x][u] + 1;
ways[x][v] = ways[x][u];
Q.push(v);
} else if (dist[x][v] == dist[x][u] + 1)
ways[x][v] += ways[x][u];
}
}
bool isLarger(array<int, 3> &x, array<int, 3> &y) {
return 1ll * x[0] * y[1] > 1ll * x[1] * y[0];
}
signed main(){
// freopen("TRAINCENTRE.inp", "r", stdin);
// freopen("TRAINCENTRE.out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> numNode >> numEdge;
for(int i = 0; i < numEdge; i++) {
int u, v;
cin >> u >> v;
G[u].push_back(v);
G[v].push_back(u);
}
cin >> numQuery;
for(int i = 0; i < numQuery; i++) {
cin >> a[i] >> b[i];
if (!computed[a[i]]) {
BFS(a[i]);
computed[a[i]] = true;
}
if (!computed[b[i]]) {
BFS(b[i]);
computed[b[i]] = true;
}
}
long double Eans = 0;
int ans = 0;
for(int w = 0; w < numNode; w++) {
long double Ew = 0;
for(int i = 0; i < numQuery; i++) {
int fixedPath = 0, totalPath = 0;
if (dist[a[i]][w] + dist[b[i]][w] == dist[a[i]][b[i]])
fixedPath += ways[a[i]][w] * ways[b[i]][w];
totalPath += ways[a[i]][b[i]];
Ew += 1.0 * fixedPath / totalPath;
}
if (Ew - Eans > eps) Eans = Ew, ans = w;
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
2 ms |
8784 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
1 ms |
4688 KB |
Output is correct |
12 |
Correct |
2 ms |
4860 KB |
Output is correct |
13 |
Correct |
1 ms |
4688 KB |
Output is correct |
14 |
Correct |
1 ms |
6736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
8 |
Correct |
4 ms |
29264 KB |
Output is correct |
9 |
Correct |
7 ms |
51792 KB |
Output is correct |
10 |
Correct |
7 ms |
47696 KB |
Output is correct |
11 |
Correct |
9 ms |
68176 KB |
Output is correct |
12 |
Correct |
2 ms |
12880 KB |
Output is correct |
13 |
Correct |
2 ms |
6736 KB |
Output is correct |
14 |
Correct |
5 ms |
31312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
2 ms |
8784 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
1 ms |
4688 KB |
Output is correct |
12 |
Correct |
2 ms |
4860 KB |
Output is correct |
13 |
Correct |
1 ms |
4688 KB |
Output is correct |
14 |
Correct |
1 ms |
6736 KB |
Output is correct |
15 |
Correct |
4 ms |
29264 KB |
Output is correct |
16 |
Correct |
7 ms |
51792 KB |
Output is correct |
17 |
Correct |
7 ms |
47696 KB |
Output is correct |
18 |
Correct |
9 ms |
68176 KB |
Output is correct |
19 |
Correct |
2 ms |
12880 KB |
Output is correct |
20 |
Correct |
2 ms |
6736 KB |
Output is correct |
21 |
Correct |
5 ms |
31312 KB |
Output is correct |
22 |
Correct |
5 ms |
35476 KB |
Output is correct |
23 |
Correct |
5 ms |
31312 KB |
Output is correct |
24 |
Correct |
7 ms |
49744 KB |
Output is correct |
25 |
Correct |
11 ms |
74320 KB |
Output is correct |
26 |
Correct |
9 ms |
70224 KB |
Output is correct |
27 |
Correct |
3 ms |
14928 KB |
Output is correct |
28 |
Correct |
6 ms |
37456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
2 ms |
8784 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
1 ms |
4688 KB |
Output is correct |
12 |
Correct |
2 ms |
4860 KB |
Output is correct |
13 |
Correct |
1 ms |
4688 KB |
Output is correct |
14 |
Correct |
1 ms |
6736 KB |
Output is correct |
15 |
Correct |
4 ms |
13048 KB |
Output is correct |
16 |
Correct |
3 ms |
8784 KB |
Output is correct |
17 |
Correct |
9 ms |
52052 KB |
Output is correct |
18 |
Correct |
7 ms |
49916 KB |
Output is correct |
19 |
Correct |
10 ms |
62460 KB |
Output is correct |
20 |
Correct |
5 ms |
19024 KB |
Output is correct |
21 |
Correct |
3 ms |
14928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
8784 KB |
Output is correct |
2 |
Correct |
1 ms |
8784 KB |
Output is correct |
3 |
Correct |
2 ms |
8784 KB |
Output is correct |
4 |
Correct |
1 ms |
4688 KB |
Output is correct |
5 |
Correct |
2 ms |
8784 KB |
Output is correct |
6 |
Correct |
3 ms |
10832 KB |
Output is correct |
7 |
Correct |
2 ms |
8784 KB |
Output is correct |
8 |
Correct |
2 ms |
6736 KB |
Output is correct |
9 |
Correct |
2 ms |
8784 KB |
Output is correct |
10 |
Correct |
2 ms |
8952 KB |
Output is correct |
11 |
Correct |
1 ms |
4688 KB |
Output is correct |
12 |
Correct |
2 ms |
4860 KB |
Output is correct |
13 |
Correct |
1 ms |
4688 KB |
Output is correct |
14 |
Correct |
1 ms |
6736 KB |
Output is correct |
15 |
Correct |
4 ms |
29264 KB |
Output is correct |
16 |
Correct |
7 ms |
51792 KB |
Output is correct |
17 |
Correct |
7 ms |
47696 KB |
Output is correct |
18 |
Correct |
9 ms |
68176 KB |
Output is correct |
19 |
Correct |
2 ms |
12880 KB |
Output is correct |
20 |
Correct |
2 ms |
6736 KB |
Output is correct |
21 |
Correct |
5 ms |
31312 KB |
Output is correct |
22 |
Correct |
5 ms |
35476 KB |
Output is correct |
23 |
Correct |
5 ms |
31312 KB |
Output is correct |
24 |
Correct |
7 ms |
49744 KB |
Output is correct |
25 |
Correct |
11 ms |
74320 KB |
Output is correct |
26 |
Correct |
9 ms |
70224 KB |
Output is correct |
27 |
Correct |
3 ms |
14928 KB |
Output is correct |
28 |
Correct |
6 ms |
37456 KB |
Output is correct |
29 |
Correct |
4 ms |
13048 KB |
Output is correct |
30 |
Correct |
3 ms |
8784 KB |
Output is correct |
31 |
Correct |
9 ms |
52052 KB |
Output is correct |
32 |
Correct |
7 ms |
49916 KB |
Output is correct |
33 |
Correct |
10 ms |
62460 KB |
Output is correct |
34 |
Correct |
5 ms |
19024 KB |
Output is correct |
35 |
Correct |
3 ms |
14928 KB |
Output is correct |
36 |
Correct |
22 ms |
21328 KB |
Output is correct |
37 |
Correct |
84 ms |
95324 KB |
Output is correct |
38 |
Correct |
626 ms |
186828 KB |
Output is correct |
39 |
Correct |
100 ms |
60896 KB |
Output is correct |
40 |
Correct |
91 ms |
132428 KB |
Output is correct |
41 |
Correct |
436 ms |
176024 KB |
Output is correct |
42 |
Correct |
227 ms |
101968 KB |
Output is correct |
43 |
Correct |
41 ms |
122704 KB |
Output is correct |
44 |
Correct |
39 ms |
117836 KB |
Output is correct |