# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105373 | 2024-10-26T08:51:31 Z | nghia0912 | Hotspot (NOI17_hotspot) | C++17 | 570 ms | 1104 KB |
#define COPYRIGHT CODE BY TRINH TUAN NGHIA #include<bits/stdc++.h> //#pragma GCC optimize("O3") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("popcnt") #define Boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define ll long long #define endl "\n" #define st first #define nd second #define ii pair <int,int> #define iii pair <int,ii> #define iiii pair <ii,ii> #define pb push_back #define NAME "traincentre" using namespace std; const int N = 5e3 + 10; const int M = 4e4 + 10; int n, m, k; vector<int> adj[N]; long double E[N]; ll d[N], d2[N]; long long f[N], f2[N]; vector<ii> cb; void BFS(int st, int en){ queue<int> q; for (int i = 0; i < n;++i){ d[i] = 3e18; d2[i] = 3e18; f[i] = 0; f2[i] = 0; } f[st] = 1; d[st] = 0; d2[en] = 0; f2[en] = 1; q.push(st); while (!q.empty()){ int u = q.front();q.pop(); for (auto v : adj[u]){ if (d[u] + 1 < d[v]){ d[v] = d[u] + 1; f[v] = f[u]; q.push(v); } else if (d[u] + 1 == d[v]){ f[v] += f[u]; } } } q.push(en); while (!q.empty()){ int u = q.front();q.pop(); for (auto v : adj[u]){ if (d2[u] + 1 < d2[v]){ d2[v] = d2[u] + 1; f2[v] = f2[u]; q.push(v); } else if (d2[u] + 1 == d2[v]){ f2[v] += f2[u]; } } } for (int i = 0; i < n; ++i){ if (d[i] + d2[i] != d[en])continue; long double cc = f[i] * f2[i]; E[i] += cc / f[en]; // cout << "Cmm " << st << " " << i << " " << cc << " " << f[en] << endl; } } void inp (){ cin >>n >> m; for (int i = 1; i <= m; ++i){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } cin >> k; for (int i =1; i <= k; ++i){ int x, y; cin>> x >> y; cb.pb({x, y}); } } void solve(){ for (auto x : cb){ BFS(x.st, x.nd); } int mx = -1; for (int i= 0; i < n; ++i){ if (mx == -1 or E[i] > E[mx]){ mx = i; } // cout << i << " " << E[i] << endl; } cout <<mx << endl; } signed main (){ if (fopen(NAME".inp", "r")){ freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout); } Boost; inp(); solve(); } /* input */ /* output */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 592 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 2 ms | 760 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 1 ms | 592 KB | Output is correct |
16 | Correct | 1 ms | 592 KB | Output is correct |
17 | Correct | 2 ms | 592 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 2 ms | 760 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 604 KB | Output is correct |
22 | Correct | 2 ms | 592 KB | Output is correct |
23 | Correct | 1 ms | 592 KB | Output is correct |
24 | Correct | 2 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 592 KB | Output is correct |
26 | Correct | 3 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 2 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 2 ms | 592 KB | Output is correct |
16 | Correct | 1 ms | 592 KB | Output is correct |
17 | Correct | 3 ms | 748 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 3 ms | 592 KB | Output is correct |
20 | Correct | 2 ms | 592 KB | Output is correct |
21 | Correct | 1 ms | 592 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 760 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 764 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 604 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 1 ms | 592 KB | Output is correct |
16 | Correct | 1 ms | 592 KB | Output is correct |
17 | Correct | 2 ms | 592 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 2 ms | 760 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 604 KB | Output is correct |
22 | Correct | 2 ms | 592 KB | Output is correct |
23 | Correct | 1 ms | 592 KB | Output is correct |
24 | Correct | 2 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 592 KB | Output is correct |
26 | Correct | 3 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 2 ms | 592 KB | Output is correct |
29 | Correct | 2 ms | 592 KB | Output is correct |
30 | Correct | 1 ms | 592 KB | Output is correct |
31 | Correct | 3 ms | 748 KB | Output is correct |
32 | Correct | 2 ms | 592 KB | Output is correct |
33 | Correct | 3 ms | 592 KB | Output is correct |
34 | Correct | 2 ms | 592 KB | Output is correct |
35 | Correct | 1 ms | 592 KB | Output is correct |
36 | Correct | 47 ms | 592 KB | Output is correct |
37 | Correct | 106 ms | 1016 KB | Output is correct |
38 | Correct | 570 ms | 1104 KB | Output is correct |
39 | Correct | 348 ms | 848 KB | Output is correct |
40 | Correct | 60 ms | 1016 KB | Output is correct |
41 | Correct | 348 ms | 1104 KB | Output is correct |
42 | Correct | 500 ms | 1104 KB | Output is correct |
43 | Correct | 26 ms | 592 KB | Output is correct |
44 | Correct | 20 ms | 592 KB | Output is correct |