답안 #1105393

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1105393 2024-10-26T09:26:55 Z TVSown Hotspot (NOI17_hotspot) C++17
38 / 100
15 ms 49144 KB
///*** Sown_Vipro ***///
/// ->GIAI BA QUOC GIA<- ///

#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#define F first
#define S second
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = a; i >= b; --i)
#define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
#define out(name) if(fopen(name, "w")) freopen(name, "w", stdout);
#define szz(s) int(s.size())
const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7;
int n, m, k;
vector<int> e[N];
vector<long long> dA(N), dB(N);
vector<int> cA(N), cB(N);
double ans[N];

void bfs(int s, vector<long long> &d, vector<int> &c){
    FOR(u, 0, n - 1){
        d[u] = 1e18;
        c[u] = 0;
    }
    d[s] = 0;
    c[s] = 1;
    queue<int> q;
    q.push(s);

    while(szz(q)){
        int u = q.front(); q.pop();
        for(int v : e[u]){
            if(d[u] + 1 < d[v]){
                d[v] = d[u] + 1;
                c[v] = c[u];
                q.push(v);
            }else if(d[u] + 1 == d[v]){
                c[v] += c[u];
            }
        }
    }
}

void solve(){
    cin >> n >> m;
    FOR(i, 1, m){
        int u, v; cin >> u >> v;
        e[u].pb(v);
        e[v].pb(u);
    }
    cin >> k;
    FOR(i, 1, k){

        int a, b; cin >> a >> b;
        bfs(a, dA, cA);
        bfs(b, dB, cB);
//        cout << a << " " << b << " " << cA[b] << "\n";
        FOR(u, 0, n - 1){
            if(dA[u] + dB[u] == dA[b]){
//                cout << u << " " << a << " " << b << " " << cA[u] << " " << cB[u] << "\n";
                ans[u] += 1.0 * cA[u] * cB[u] / cA[b];
            }
        }
    }

    int r1 = 0, r2 = 0;
    FOR(u, 0, n - 1){
//        cout << u << " " << ans[u] << "\n";
        if(ans[u] > r1){
            r1 = ans[u];
            r2 = u;
        }
    }

    cout << r2;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    inp("in.txt");
    int t = 1;
//    cin >> t;
    while(t--){
        solve();
    }
}

Compilation message

hotspot.cpp: In function 'int main()':
hotspot.cpp:16:47: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 | #define inp(name) if(fopen(name, "r")) freopen(name, "r", stdin);
      |                                        ~~~~~~~^~~~~~~~~~~~~~~~~~
hotspot.cpp:87:5: note: in expansion of macro 'inp'
   87 |     inp("in.txt");
      |     ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
8 Correct 11 ms 48720 KB Output is correct
9 Correct 11 ms 48720 KB Output is correct
10 Correct 11 ms 48976 KB Output is correct
11 Correct 11 ms 48720 KB Output is correct
12 Correct 11 ms 48720 KB Output is correct
13 Correct 11 ms 48720 KB Output is correct
14 Correct 11 ms 48720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
8 Correct 11 ms 48720 KB Output is correct
9 Correct 11 ms 48720 KB Output is correct
10 Correct 11 ms 48720 KB Output is correct
11 Correct 12 ms 48720 KB Output is correct
12 Correct 11 ms 48720 KB Output is correct
13 Correct 12 ms 48720 KB Output is correct
14 Correct 12 ms 48720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
8 Correct 11 ms 48720 KB Output is correct
9 Correct 11 ms 48720 KB Output is correct
10 Correct 11 ms 48976 KB Output is correct
11 Correct 11 ms 48720 KB Output is correct
12 Correct 11 ms 48720 KB Output is correct
13 Correct 11 ms 48720 KB Output is correct
14 Correct 11 ms 48720 KB Output is correct
15 Correct 11 ms 48720 KB Output is correct
16 Correct 11 ms 48720 KB Output is correct
17 Correct 11 ms 48720 KB Output is correct
18 Correct 12 ms 48720 KB Output is correct
19 Correct 11 ms 48720 KB Output is correct
20 Correct 12 ms 48720 KB Output is correct
21 Correct 12 ms 48720 KB Output is correct
22 Correct 11 ms 48720 KB Output is correct
23 Correct 12 ms 48720 KB Output is correct
24 Correct 12 ms 48720 KB Output is correct
25 Correct 12 ms 48976 KB Output is correct
26 Correct 13 ms 48976 KB Output is correct
27 Correct 13 ms 48736 KB Output is correct
28 Correct 14 ms 48720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
8 Correct 11 ms 48720 KB Output is correct
9 Correct 11 ms 48720 KB Output is correct
10 Correct 11 ms 48976 KB Output is correct
11 Correct 11 ms 48720 KB Output is correct
12 Correct 11 ms 48720 KB Output is correct
13 Correct 11 ms 48720 KB Output is correct
14 Correct 11 ms 48720 KB Output is correct
15 Correct 13 ms 49144 KB Output is correct
16 Correct 12 ms 48976 KB Output is correct
17 Correct 15 ms 48976 KB Output is correct
18 Correct 12 ms 48976 KB Output is correct
19 Correct 14 ms 48976 KB Output is correct
20 Correct 13 ms 48976 KB Output is correct
21 Incorrect 12 ms 48720 KB Output isn't correct
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 48720 KB Output is correct
2 Correct 11 ms 48732 KB Output is correct
3 Correct 11 ms 48720 KB Output is correct
4 Correct 11 ms 48720 KB Output is correct
5 Correct 11 ms 48720 KB Output is correct
6 Correct 11 ms 48720 KB Output is correct
7 Correct 11 ms 48720 KB Output is correct
8 Correct 11 ms 48720 KB Output is correct
9 Correct 11 ms 48720 KB Output is correct
10 Correct 11 ms 48976 KB Output is correct
11 Correct 11 ms 48720 KB Output is correct
12 Correct 11 ms 48720 KB Output is correct
13 Correct 11 ms 48720 KB Output is correct
14 Correct 11 ms 48720 KB Output is correct
15 Correct 11 ms 48720 KB Output is correct
16 Correct 11 ms 48720 KB Output is correct
17 Correct 11 ms 48720 KB Output is correct
18 Correct 12 ms 48720 KB Output is correct
19 Correct 11 ms 48720 KB Output is correct
20 Correct 12 ms 48720 KB Output is correct
21 Correct 12 ms 48720 KB Output is correct
22 Correct 11 ms 48720 KB Output is correct
23 Correct 12 ms 48720 KB Output is correct
24 Correct 12 ms 48720 KB Output is correct
25 Correct 12 ms 48976 KB Output is correct
26 Correct 13 ms 48976 KB Output is correct
27 Correct 13 ms 48736 KB Output is correct
28 Correct 14 ms 48720 KB Output is correct
29 Correct 13 ms 49144 KB Output is correct
30 Correct 12 ms 48976 KB Output is correct
31 Correct 15 ms 48976 KB Output is correct
32 Correct 12 ms 48976 KB Output is correct
33 Correct 14 ms 48976 KB Output is correct
34 Correct 13 ms 48976 KB Output is correct
35 Incorrect 12 ms 48720 KB Output isn't correct
36 Halted 0 ms 0 KB -