Submission #738173

# Submission time Handle Problem Language Result Execution time Memory
738173 2023-05-08T08:40:02 Z Ronin13 Hotspot (NOI17_hotspot) C++14
100 / 100
900 ms 7032 KB
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
const int nmax = 200001;

vector <vector <int>  > g(nmax);
vector <double> ans(nmax);
int n;

void BFS(int a, int b){
    queue <int> q;
    vector <int> dp(n + 1, 0);
    dp[a] = 1;
    vector <int> d(n + 1, 1e9);
    d[a] = 0;
    q.push(a);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int to : g[v]){
            if(d[to] == d[v]) continue;
            if(d[to] > d[v]) dp[to] += dp[v];
            if(d[to] == 1e9) d[to] = d[v] + 1, q.push(to);
        }
    }
    int x = d[b];
    vector <int> DP(n + 1, 0);
    swap(a, b);
    DP[a] = 1;
    vector <int> D(n + 1, 1e9);
    D[a] = 0;
    q.push(a);
    while(!q.empty()){
        int v = q.front(); q.pop();
        for(int to : g[v]){
            if(D[to] <= D[v]) continue;
            if(D[to] > D[v]) DP[to] += DP[v];
            if(D[to] == 1e9) D[to] = D[v] + 1, q.push(to);
        }
    }
    for(int i = 0; i < n; ++i){
        if(d[i] + D[i] != x) continue;
        double x = dp[i] * DP[i];
       // cout << x << ' ';
        double t = DP[a] * dp[a];
        ans[i] += x / t;
    }
  //  cout << "\n";
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    int  m; cin >> n >> m;
    int k;
    for(int i= 1; i <= m; i++){
        int u, v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    cin >> k;
    for(int i = 1; i <= k; i++){
        int a, b; cin >> a >> b;
        BFS(a, b);
    }
    double mx = 0, mxi = 0;
    for(int i = 0; i < n; i++){
        //cout << ans[i] << "\n";
        if(ans[i] > mx)
            mx = ans[i], mxi = i;
    }
    cout << mxi;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 4 ms 6612 KB Output is correct
10 Correct 4 ms 6516 KB Output is correct
11 Correct 4 ms 6484 KB Output is correct
12 Correct 4 ms 6484 KB Output is correct
13 Correct 3 ms 6612 KB Output is correct
14 Correct 3 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
8 Correct 4 ms 6484 KB Output is correct
9 Correct 5 ms 6612 KB Output is correct
10 Correct 5 ms 6612 KB Output is correct
11 Correct 6 ms 6612 KB Output is correct
12 Correct 4 ms 6484 KB Output is correct
13 Correct 4 ms 6484 KB Output is correct
14 Correct 5 ms 6484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 4 ms 6612 KB Output is correct
10 Correct 4 ms 6516 KB Output is correct
11 Correct 4 ms 6484 KB Output is correct
12 Correct 4 ms 6484 KB Output is correct
13 Correct 3 ms 6612 KB Output is correct
14 Correct 3 ms 6612 KB Output is correct
15 Correct 4 ms 6484 KB Output is correct
16 Correct 5 ms 6612 KB Output is correct
17 Correct 5 ms 6612 KB Output is correct
18 Correct 6 ms 6612 KB Output is correct
19 Correct 4 ms 6484 KB Output is correct
20 Correct 4 ms 6484 KB Output is correct
21 Correct 5 ms 6484 KB Output is correct
22 Correct 4 ms 6612 KB Output is correct
23 Correct 4 ms 6612 KB Output is correct
24 Correct 5 ms 6612 KB Output is correct
25 Correct 6 ms 6612 KB Output is correct
26 Correct 6 ms 6612 KB Output is correct
27 Correct 4 ms 6484 KB Output is correct
28 Correct 5 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 4 ms 6612 KB Output is correct
10 Correct 4 ms 6516 KB Output is correct
11 Correct 4 ms 6484 KB Output is correct
12 Correct 4 ms 6484 KB Output is correct
13 Correct 3 ms 6612 KB Output is correct
14 Correct 3 ms 6612 KB Output is correct
15 Correct 4 ms 6612 KB Output is correct
16 Correct 4 ms 6612 KB Output is correct
17 Correct 10 ms 6612 KB Output is correct
18 Correct 6 ms 6660 KB Output is correct
19 Correct 7 ms 6612 KB Output is correct
20 Correct 6 ms 6612 KB Output is correct
21 Correct 4 ms 6612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6612 KB Output is correct
2 Correct 4 ms 6612 KB Output is correct
3 Correct 3 ms 6612 KB Output is correct
4 Correct 4 ms 6484 KB Output is correct
5 Correct 3 ms 6484 KB Output is correct
6 Correct 3 ms 6484 KB Output is correct
7 Correct 4 ms 6612 KB Output is correct
8 Correct 3 ms 6484 KB Output is correct
9 Correct 4 ms 6612 KB Output is correct
10 Correct 4 ms 6516 KB Output is correct
11 Correct 4 ms 6484 KB Output is correct
12 Correct 4 ms 6484 KB Output is correct
13 Correct 3 ms 6612 KB Output is correct
14 Correct 3 ms 6612 KB Output is correct
15 Correct 4 ms 6484 KB Output is correct
16 Correct 5 ms 6612 KB Output is correct
17 Correct 5 ms 6612 KB Output is correct
18 Correct 6 ms 6612 KB Output is correct
19 Correct 4 ms 6484 KB Output is correct
20 Correct 4 ms 6484 KB Output is correct
21 Correct 5 ms 6484 KB Output is correct
22 Correct 4 ms 6612 KB Output is correct
23 Correct 4 ms 6612 KB Output is correct
24 Correct 5 ms 6612 KB Output is correct
25 Correct 6 ms 6612 KB Output is correct
26 Correct 6 ms 6612 KB Output is correct
27 Correct 4 ms 6484 KB Output is correct
28 Correct 5 ms 6612 KB Output is correct
29 Correct 4 ms 6612 KB Output is correct
30 Correct 4 ms 6612 KB Output is correct
31 Correct 10 ms 6612 KB Output is correct
32 Correct 6 ms 6660 KB Output is correct
33 Correct 7 ms 6612 KB Output is correct
34 Correct 6 ms 6612 KB Output is correct
35 Correct 4 ms 6612 KB Output is correct
36 Correct 82 ms 6612 KB Output is correct
37 Correct 184 ms 6828 KB Output is correct
38 Correct 900 ms 7004 KB Output is correct
39 Correct 579 ms 7020 KB Output is correct
40 Correct 96 ms 6740 KB Output is correct
41 Correct 523 ms 7020 KB Output is correct
42 Correct 666 ms 7032 KB Output is correct
43 Correct 44 ms 6612 KB Output is correct
44 Correct 40 ms 6712 KB Output is correct