답안 #765159

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
765159 2023-06-24T08:54:30 Z Trisanu_Das Hotspot (NOI17_hotspot) C++17
100 / 100
554 ms 1128 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=5000, INF=1e9;
int n, m, k;
double dp[mxN];
ar<int, 2> d1[mxN], d2[mxN];
vector<int> adj[mxN];
 
void bfs(int s, ar<int, 2>* d) {
	memset(d, -1, 8*n);
	d[s]={0, 1};
	for (queue<int> q({s}); q.size(); q.pop()) {
		int u=q.front();
		for (int v : adj[u]) {
			if (d[v][0]==-1) {
				d[v]={d[u][0]+1, d[u][1]};
				q.push(v);
			} else if (d[u][0]+1==d[v][0]) d[v][1]+=d[u][1];
		}
	}
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m;
	for (int i=0; i<m; ++i) {
		int u, v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	cin >> k;
	while(k--) {
		int u, v;
		cin >> u >> v;
		bfs(u, d1);
		bfs(v, d2);
		double t=d1[v][1];
		for (int j=0; j<n; ++j) if (d1[j][0]+d2[j][0]==d1[v][0]) dp[j]+=d1[j][1]*d2[j][1]/t;
	}
	cout << max_element(dp, dp+n)-dp;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 2 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 452 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 2 ms 496 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 2 ms 596 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 452 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 452 KB Output is correct
25 Correct 3 ms 468 KB Output is correct
26 Correct 2 ms 468 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 452 KB Output is correct
29 Correct 2 ms 596 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 3 ms 596 KB Output is correct
32 Correct 2 ms 496 KB Output is correct
33 Correct 3 ms 596 KB Output is correct
34 Correct 2 ms 596 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 47 ms 588 KB Output is correct
37 Correct 106 ms 792 KB Output is correct
38 Correct 554 ms 1120 KB Output is correct
39 Correct 342 ms 1108 KB Output is correct
40 Correct 58 ms 768 KB Output is correct
41 Correct 335 ms 1128 KB Output is correct
42 Correct 492 ms 1100 KB Output is correct
43 Correct 26 ms 596 KB Output is correct
44 Correct 27 ms 656 KB Output is correct