# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105366 | 2024-10-26T08:39:44 Z | LTTrungCHL | Hotspot (NOI17_hotspot) | C++17 | 5 ms | 10832 KB |
///***LTT***/// /// ->NHAT QUOC GIA<- /// #include<bits/stdc++.h> //#pragma GCC optimize ("O3") //#pragma GCC optimize ("unroll-loops") //#pragma GCC target("popcnt") #define int long long #define endl "\n" #define F first #define S second #define pb push_back using namespace std; vector <int> lg2; //void MAKE_LOG_ARR(int n){ // lg2.resize(n + 3); // for (int i = 1;i <= n;++i){ // lg2[i] = __lg(i); // } //} const long long oo = 1e9+7; const int N = 2 * 1e5 + 10; int n, m; pair <int ,int> disa[N], disb[N]; vector <int> adj[N]; queue <int> q; pair <long double ,int> e[N]; void solve(){ cin >> n >> m; for (int i = 0;i < n;++i){ e[i].S = i; } for (int i = 1;i <= m;++i){ int u, v; cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } int k; cin >> k; for (int ik = 1;ik <= k;++ik){ int a, b; cin >> a >> b; for (int i = 0;i < n;++i){ disa[i] = {oo, 0}; disb[i] = {oo, 0}; } disa[a] = {1,1}; disb[b] = {1,1}; q.push(a); while (!q.empty()){ int u = q.front(); q.pop(); for (int v : adj[u]){ if (disa[u].F + 1 == disa[v].F){ disa[v].S += disa[u].S; } if (disa[u].F + 1 < disa[v].F){ disa[v].F = disa[u].F + 1; disa[v].S = disa[u].S; q.push(v); } } } q.push(b); while (!q.empty()){ int u = q.front(); q.pop(); for (int v : adj[u]){ if (disb[u].F + 1 == disb[v].F){ disb[v].S += disb[u].S; } if (disb[u].F + 1 < disb[v].F){ disb[v].F = disb[u].F + 1; disb[v].S = disb[u].S; q.push(v); } } } for (int i = 0;i < n;++i){ int mia = oo; int mib = oo; for (int v : adj[i]){ mia = min(mia, disa[v].F); mib = min(mib, disb[v].F); } if (mia + mib + 1 != disa[b].F) continue; int suma = 0; int sumb = 0; for (int v : adj[i]){ if (disa[v].F == mia){ suma += disa[v].S; } if (disb[v].F == mib){ sumb += disb[v].S; } } long double tmp =(suma * sumb); long double tmp2 = disa[b].S; e[i].F += tmp/ tmp2; } e[a].F += disa[b].S; e[b].F += disa[b].S; } sort(e ,e + n); cout << e[n - 1].S; return; } signed main(){ ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL); if (fopen("ltt.inp", "r")){ freopen("ltt.inp", "r", stdin); freopen("ltt.out", "w", stdout); } // int t; // cin >> t; // while(t--){ solve(); // } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
8 | Correct | 2 ms | 10576 KB | Output is correct |
9 | Correct | 2 ms | 10576 KB | Output is correct |
10 | Correct | 2 ms | 10576 KB | Output is correct |
11 | Correct | 2 ms | 10744 KB | Output is correct |
12 | Correct | 2 ms | 10576 KB | Output is correct |
13 | Correct | 2 ms | 10576 KB | Output is correct |
14 | Correct | 2 ms | 10576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
8 | Correct | 2 ms | 10576 KB | Output is correct |
9 | Correct | 3 ms | 10576 KB | Output is correct |
10 | Correct | 3 ms | 10576 KB | Output is correct |
11 | Correct | 3 ms | 10780 KB | Output is correct |
12 | Correct | 2 ms | 10576 KB | Output is correct |
13 | Correct | 3 ms | 10576 KB | Output is correct |
14 | Correct | 3 ms | 10576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
8 | Correct | 2 ms | 10576 KB | Output is correct |
9 | Correct | 2 ms | 10576 KB | Output is correct |
10 | Correct | 2 ms | 10576 KB | Output is correct |
11 | Correct | 2 ms | 10744 KB | Output is correct |
12 | Correct | 2 ms | 10576 KB | Output is correct |
13 | Correct | 2 ms | 10576 KB | Output is correct |
14 | Correct | 2 ms | 10576 KB | Output is correct |
15 | Correct | 2 ms | 10576 KB | Output is correct |
16 | Correct | 3 ms | 10576 KB | Output is correct |
17 | Correct | 3 ms | 10576 KB | Output is correct |
18 | Correct | 3 ms | 10780 KB | Output is correct |
19 | Correct | 2 ms | 10576 KB | Output is correct |
20 | Correct | 3 ms | 10576 KB | Output is correct |
21 | Correct | 3 ms | 10576 KB | Output is correct |
22 | Correct | 2 ms | 10576 KB | Output is correct |
23 | Correct | 4 ms | 10576 KB | Output is correct |
24 | Correct | 3 ms | 10588 KB | Output is correct |
25 | Correct | 4 ms | 10576 KB | Output is correct |
26 | Correct | 4 ms | 10576 KB | Output is correct |
27 | Correct | 3 ms | 10744 KB | Output is correct |
28 | Correct | 4 ms | 10576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
8 | Correct | 2 ms | 10576 KB | Output is correct |
9 | Correct | 2 ms | 10576 KB | Output is correct |
10 | Correct | 2 ms | 10576 KB | Output is correct |
11 | Correct | 2 ms | 10744 KB | Output is correct |
12 | Correct | 2 ms | 10576 KB | Output is correct |
13 | Correct | 2 ms | 10576 KB | Output is correct |
14 | Correct | 2 ms | 10576 KB | Output is correct |
15 | Correct | 3 ms | 10832 KB | Output is correct |
16 | Correct | 2 ms | 10832 KB | Output is correct |
17 | Incorrect | 5 ms | 10832 KB | Output isn't correct |
18 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 10576 KB | Output is correct |
2 | Correct | 2 ms | 10604 KB | Output is correct |
3 | Correct | 2 ms | 10576 KB | Output is correct |
4 | Correct | 2 ms | 10576 KB | Output is correct |
5 | Correct | 2 ms | 10576 KB | Output is correct |
6 | Correct | 2 ms | 10576 KB | Output is correct |
7 | Correct | 2 ms | 10576 KB | Output is correct |
8 | Correct | 2 ms | 10576 KB | Output is correct |
9 | Correct | 2 ms | 10576 KB | Output is correct |
10 | Correct | 2 ms | 10576 KB | Output is correct |
11 | Correct | 2 ms | 10744 KB | Output is correct |
12 | Correct | 2 ms | 10576 KB | Output is correct |
13 | Correct | 2 ms | 10576 KB | Output is correct |
14 | Correct | 2 ms | 10576 KB | Output is correct |
15 | Correct | 2 ms | 10576 KB | Output is correct |
16 | Correct | 3 ms | 10576 KB | Output is correct |
17 | Correct | 3 ms | 10576 KB | Output is correct |
18 | Correct | 3 ms | 10780 KB | Output is correct |
19 | Correct | 2 ms | 10576 KB | Output is correct |
20 | Correct | 3 ms | 10576 KB | Output is correct |
21 | Correct | 3 ms | 10576 KB | Output is correct |
22 | Correct | 2 ms | 10576 KB | Output is correct |
23 | Correct | 4 ms | 10576 KB | Output is correct |
24 | Correct | 3 ms | 10588 KB | Output is correct |
25 | Correct | 4 ms | 10576 KB | Output is correct |
26 | Correct | 4 ms | 10576 KB | Output is correct |
27 | Correct | 3 ms | 10744 KB | Output is correct |
28 | Correct | 4 ms | 10576 KB | Output is correct |
29 | Correct | 3 ms | 10832 KB | Output is correct |
30 | Correct | 2 ms | 10832 KB | Output is correct |
31 | Incorrect | 5 ms | 10832 KB | Output isn't correct |
32 | Halted | 0 ms | 0 KB | - |