답안 #776568

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
776568 2023-07-08T04:08:23 Z Cookie Hotspot (NOI17_hotspot) C++14
20 / 100
17 ms 24000 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{
                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);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23808 KB Output is correct
9 Correct 13 ms 23824 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23732 KB Output is correct
13 Correct 15 ms 23820 KB Output is correct
14 Correct 13 ms 23796 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 13 ms 23852 KB Output is correct
9 Correct 13 ms 23832 KB Output is correct
10 Correct 13 ms 23800 KB Output is correct
11 Correct 17 ms 23892 KB Output is correct
12 Correct 13 ms 23764 KB Output is correct
13 Correct 13 ms 23836 KB Output is correct
14 Correct 13 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23808 KB Output is correct
9 Correct 13 ms 23824 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23732 KB Output is correct
13 Correct 15 ms 23820 KB Output is correct
14 Correct 13 ms 23796 KB Output is correct
15 Correct 13 ms 23852 KB Output is correct
16 Correct 13 ms 23832 KB Output is correct
17 Correct 13 ms 23800 KB Output is correct
18 Correct 17 ms 23892 KB Output is correct
19 Correct 13 ms 23764 KB Output is correct
20 Correct 13 ms 23836 KB Output is correct
21 Correct 13 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Incorrect 12 ms 23764 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23808 KB Output is correct
9 Correct 13 ms 23824 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23732 KB Output is correct
13 Correct 15 ms 23820 KB Output is correct
14 Correct 13 ms 23796 KB Output is correct
15 Correct 13 ms 24000 KB Output is correct
16 Incorrect 14 ms 23828 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 14 ms 23864 KB Output is correct
3 Correct 12 ms 23828 KB Output is correct
4 Correct 14 ms 23732 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 12 ms 23728 KB Output is correct
7 Correct 11 ms 23764 KB Output is correct
8 Correct 11 ms 23808 KB Output is correct
9 Correct 13 ms 23824 KB Output is correct
10 Correct 13 ms 23888 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 13 ms 23732 KB Output is correct
13 Correct 15 ms 23820 KB Output is correct
14 Correct 13 ms 23796 KB Output is correct
15 Correct 13 ms 23852 KB Output is correct
16 Correct 13 ms 23832 KB Output is correct
17 Correct 13 ms 23800 KB Output is correct
18 Correct 17 ms 23892 KB Output is correct
19 Correct 13 ms 23764 KB Output is correct
20 Correct 13 ms 23836 KB Output is correct
21 Correct 13 ms 23764 KB Output is correct
22 Correct 12 ms 23764 KB Output is correct
23 Incorrect 12 ms 23764 KB Output isn't correct
24 Halted 0 ms 0 KB -