Submission #776569

# Submission time Handle Problem Language Result Execution time Memory
776569 2023-07-08T04:09:07 Z Cookie Hotspot (NOI17_hotspot) C++14
100 / 100
643 ms 25000 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("HAMMING.INP");
ofstream fout("HAMMING.OUT");
#define sz(a) (int)a.size()
#define int long long
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;

//const int x[4] = {1, -1, 0, 0};
const int y[4] = {0, 0, 1, -1};
 const ll mod = 1e9 + 7,inf =1e18;
const ll mxn = 1e6 + 5, sq = 500, mxv = 1e6 + 5;
int n, m;
vt<int>adj[mxn + 1];
ld ans[mxn + 1];
vt<pii>bfs(int s){
    vt<pii>dis; dis.resize(n + 1);
    for(int i = 0; i < n; i++)dis[i].fi = 1e9;
    dis[s] = make_pair(0, 1);
    queue<int>q; q.push(s);
    while(!q.empty()){
        int nw = q.front(); q.pop();
        for(auto i: adj[nw]){
            if(dis[i].fi > dis[nw].fi + 1){
                dis[i].fi = dis[nw].fi + 1; dis[i].se = dis[nw].se;
                q.push(i);
            }else if(dis[i].fi == dis[nw].fi + 1){
                dis[i].se += dis[nw].se;
            }
        }
    }
    return(dis);
}
signed main()
{
     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    forr(i, 0, m){
        int u, v; cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
    int k; cin >> k;
    while(k--){
        int a, b; cin >> a >> b;
        vt<pii>d = bfs(a), d2 = bfs(b);
        for(int i = 0; i < n; i++){
            if(d[i].fi + d2[i].fi == d[b].fi){
                ans[i] += (ld)(d[i].se * d2[i].se) / (d[b].se);
            }
        }
    }
    ld mx = -1; int id = -1;
    for(int i = 0; i < n; i++){
        if(ans[i] > mx){
            mx = ans[i]; id = i;
        }
    }
    cout << id;
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23772 KB Output is correct
10 Correct 12 ms 23844 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 13 ms 23812 KB Output is correct
13 Correct 12 ms 23852 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23800 KB Output is correct
9 Correct 13 ms 23764 KB Output is correct
10 Correct 12 ms 23764 KB Output is correct
11 Correct 15 ms 23892 KB Output is correct
12 Correct 11 ms 23764 KB Output is correct
13 Correct 12 ms 23764 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23772 KB Output is correct
10 Correct 12 ms 23844 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 13 ms 23812 KB Output is correct
13 Correct 12 ms 23852 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
15 Correct 12 ms 23800 KB Output is correct
16 Correct 13 ms 23764 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 15 ms 23892 KB Output is correct
19 Correct 11 ms 23764 KB Output is correct
20 Correct 12 ms 23764 KB Output is correct
21 Correct 13 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 13 ms 23844 KB Output is correct
25 Correct 14 ms 23820 KB Output is correct
26 Correct 14 ms 23892 KB Output is correct
27 Correct 14 ms 23764 KB Output is correct
28 Correct 14 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23772 KB Output is correct
10 Correct 12 ms 23844 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 13 ms 23812 KB Output is correct
13 Correct 12 ms 23852 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
15 Correct 13 ms 23972 KB Output is correct
16 Correct 13 ms 23844 KB Output is correct
17 Correct 15 ms 24100 KB Output is correct
18 Correct 14 ms 23832 KB Output is correct
19 Correct 14 ms 24012 KB Output is correct
20 Correct 13 ms 23908 KB Output is correct
21 Correct 12 ms 23776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23804 KB Output is correct
2 Correct 13 ms 23764 KB Output is correct
3 Correct 15 ms 23792 KB Output is correct
4 Correct 12 ms 23692 KB Output is correct
5 Correct 12 ms 23764 KB Output is correct
6 Correct 12 ms 23764 KB Output is correct
7 Correct 12 ms 23764 KB Output is correct
8 Correct 12 ms 23764 KB Output is correct
9 Correct 12 ms 23772 KB Output is correct
10 Correct 12 ms 23844 KB Output is correct
11 Correct 12 ms 23764 KB Output is correct
12 Correct 13 ms 23812 KB Output is correct
13 Correct 12 ms 23852 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
15 Correct 12 ms 23800 KB Output is correct
16 Correct 13 ms 23764 KB Output is correct
17 Correct 12 ms 23764 KB Output is correct
18 Correct 15 ms 23892 KB Output is correct
19 Correct 11 ms 23764 KB Output is correct
20 Correct 12 ms 23764 KB Output is correct
21 Correct 13 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Correct 12 ms 23764 KB Output is correct
24 Correct 13 ms 23844 KB Output is correct
25 Correct 14 ms 23820 KB Output is correct
26 Correct 14 ms 23892 KB Output is correct
27 Correct 14 ms 23764 KB Output is correct
28 Correct 14 ms 23764 KB Output is correct
29 Correct 13 ms 23972 KB Output is correct
30 Correct 13 ms 23844 KB Output is correct
31 Correct 15 ms 24100 KB Output is correct
32 Correct 14 ms 23832 KB Output is correct
33 Correct 14 ms 24012 KB Output is correct
34 Correct 13 ms 23908 KB Output is correct
35 Correct 12 ms 23776 KB Output is correct
36 Correct 60 ms 24192 KB Output is correct
37 Correct 127 ms 24276 KB Output is correct
38 Correct 643 ms 24904 KB Output is correct
39 Correct 434 ms 24960 KB Output is correct
40 Correct 81 ms 24428 KB Output is correct
41 Correct 391 ms 24788 KB Output is correct
42 Correct 568 ms 25000 KB Output is correct
43 Correct 39 ms 24148 KB Output is correct
44 Correct 37 ms 24088 KB Output is correct