# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1105391 | 2024-10-26T09:17:57 Z | whoknow | Hotspot (NOI17_hotspot) | C++17 | 685 ms | 1604 KB |
#include <bits/stdc++.h> #define ll long long #define int long long #define F first #define S second #define MAXN 5005 #define MAXEDGE 40005 #define ii pair<ll,int> #define bit(i,j) ((i>>j)&1) #define sz(i) (int)i.size() #define endl '\n' using namespace std; int n, m, k; vector<int>g[MAXN]; namespace sub1 { double dp[MAXN]; ii d[MAXN][2]; bool visited[MAXN]; void bfs(int st, int j) { for(int i = 0; i <= n; i++) { visited[i] = 0; d[i][j] = {1e18, 0}; } queue<int>q; q.push(st); d[st][j] = {0, 1}; while(q.empty() != 1) { int u = q.front(); q.pop(); if(visited[u]) continue; visited[u] = 1; for(int v : g[u]) { if(d[v][j].F > d[u][j].F + 1) { d[v][j] = {d[u][j].F + 1, d[u][j].S}; q.push(v); } else if(d[v][j].F == d[u][j].F + 1) d[v][j].S += d[u][j].S; } } } void calc(int st, int ed) { for(int i = 0; i < n; i++) { if(d[i][0].F + d[i][1].F == d[ed][0].F) { double t = 1.0 * d[i][0].S * d[i][1].S, t1 = max(d[st][1].S, d[ed][0].S); double x=1.0*t/t1; dp[i] += x; } // cout << setprecision(3) << fixed << dp[i] << endl; } } void solve() { cin >> k; for(int i = 1; i <= k; i++) { int x, y; cin >> x >> y; bfs(x, 0); bfs(y, 1); // cout << i << ": "; calc(x, y); } int res = 0; for(int i = 0; i < n; i++) { if(dp[i] > dp[res]) res = i; } cout << res; } } main() { if(fopen("TEST.inp", "r")) { freopen("TEST.inp", "r", stdin); freopen("TEST.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= m; i++) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } sub1::solve(); } /** 4 6 0 1 1 2 2 3 3 0 0 2 3 1 3 0 2 3 2 1 2 **/
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
8 | Correct | 1 ms | 760 KB | Output is correct |
9 | Correct | 2 ms | 592 KB | Output is correct |
10 | Correct | 2 ms | 760 KB | Output is correct |
11 | Correct | 2 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 2 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 1 ms | 760 KB | Output is correct |
16 | Correct | 2 ms | 592 KB | Output is correct |
17 | Correct | 2 ms | 760 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 1 ms | 592 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 592 KB | Output is correct |
22 | Correct | 2 ms | 592 KB | Output is correct |
23 | Correct | 2 ms | 592 KB | Output is correct |
24 | Correct | 2 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 592 KB | Output is correct |
26 | Correct | 3 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 3 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 2 ms | 592 KB | Output is correct |
16 | Correct | 2 ms | 592 KB | Output is correct |
17 | Correct | 4 ms | 632 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 4 ms | 592 KB | Output is correct |
20 | Correct | 2 ms | 592 KB | Output is correct |
21 | Correct | 1 ms | 592 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 592 KB | Output is correct |
2 | Correct | 1 ms | 592 KB | Output is correct |
3 | Correct | 1 ms | 592 KB | Output is correct |
4 | Correct | 1 ms | 592 KB | Output is correct |
5 | Correct | 1 ms | 592 KB | Output is correct |
6 | Correct | 1 ms | 592 KB | Output is correct |
7 | Correct | 1 ms | 592 KB | Output is correct |
8 | Correct | 1 ms | 592 KB | Output is correct |
9 | Correct | 1 ms | 592 KB | Output is correct |
10 | Correct | 1 ms | 592 KB | Output is correct |
11 | Correct | 1 ms | 592 KB | Output is correct |
12 | Correct | 1 ms | 592 KB | Output is correct |
13 | Correct | 1 ms | 592 KB | Output is correct |
14 | Correct | 1 ms | 592 KB | Output is correct |
15 | Correct | 1 ms | 760 KB | Output is correct |
16 | Correct | 2 ms | 592 KB | Output is correct |
17 | Correct | 2 ms | 760 KB | Output is correct |
18 | Correct | 2 ms | 592 KB | Output is correct |
19 | Correct | 1 ms | 592 KB | Output is correct |
20 | Correct | 1 ms | 592 KB | Output is correct |
21 | Correct | 2 ms | 592 KB | Output is correct |
22 | Correct | 2 ms | 592 KB | Output is correct |
23 | Correct | 2 ms | 592 KB | Output is correct |
24 | Correct | 2 ms | 592 KB | Output is correct |
25 | Correct | 2 ms | 592 KB | Output is correct |
26 | Correct | 3 ms | 592 KB | Output is correct |
27 | Correct | 1 ms | 592 KB | Output is correct |
28 | Correct | 3 ms | 592 KB | Output is correct |
29 | Correct | 2 ms | 592 KB | Output is correct |
30 | Correct | 2 ms | 592 KB | Output is correct |
31 | Correct | 4 ms | 632 KB | Output is correct |
32 | Correct | 2 ms | 592 KB | Output is correct |
33 | Correct | 4 ms | 592 KB | Output is correct |
34 | Correct | 2 ms | 592 KB | Output is correct |
35 | Correct | 1 ms | 592 KB | Output is correct |
36 | Correct | 48 ms | 848 KB | Output is correct |
37 | Correct | 120 ms | 848 KB | Output is correct |
38 | Correct | 685 ms | 1604 KB | Output is correct |
39 | Correct | 412 ms | 1360 KB | Output is correct |
40 | Correct | 63 ms | 848 KB | Output is correct |
41 | Correct | 421 ms | 1360 KB | Output is correct |
42 | Correct | 558 ms | 1360 KB | Output is correct |
43 | Correct | 24 ms | 848 KB | Output is correct |
44 | Correct | 21 ms | 848 KB | Output is correct |