Submission #684453

# Submission time Handle Problem Language Result Execution time Memory
684453 2023-01-21T09:44:02 Z dsyz Hotspot (NOI17_hotspot) C++17
38 / 100
10 ms 596 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = double;
#define MAXN (1000005)
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);
	ll N,M;
	cin>>N>>M;
	vector<ll> v[N];
	for(ll i = 0;i < M;i++){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	ll K;
	cin>>K;
	pair<ll,ll> arr[K];
	for(ll i = 0;i < K;i++){
		cin>>arr[i].first>>arr[i].second;
	}
	queue<ll> q;
	ld ans[N];
	memset(ans,0,sizeof(ans));
	pair<ll,ll> dist1[N];
	pair<ll,ll> dist2[N];
	for(ll person = 0;person < K;person++){
		ll A = arr[person].first;
		ll B = arr[person].second;
		for(ll i = 0;i < N;i++) dist1[i] = {-1,0};
		q.push(A);
		dist1[A] = {0,1};
		while(!q.empty()){
			ll x = q.front();
			q.pop();
			for(auto u : v[x]){
				if(dist1[u].first == -1 || dist1[x].first + 1 < dist1[u].first){
					q.push(u);
					dist1[u] = {dist1[x].first + 1,dist1[x].second};
				}else if(dist1[x].first + 1 == dist1[u].first){
					q.push(u);
					dist1[u].second += dist1[x].second;
				}
			}
		}
		
		for(ll i = 0;i < N;i++) dist2[i] = {-1,0};
		q.push(B);
		dist2[B] = {0,1};
		while(!q.empty()){
			ll x = q.front();
			q.pop();
			for(auto u : v[x]){
				if(dist2[u].first == -1 || dist2[x].first + 1 < dist2[u].first){
					q.push(u);
					dist2[u] = {dist2[x].first + 1,dist2[x].second};
				}else if(dist2[x].first + 1 == dist2[u].first){
					q.push(u);
					dist2[u].second += dist2[x].second;
				}
			}
		}
		
		for(ll i = 0;i < N;i++){
			if(dist1[i].first + dist2[i].first == dist1[B].first){
				ans[i] += ld(dist1[i].second * dist2[i].second) / ld(dist1[B].second);
			}
		}
	}
	ld maximum = 0;
	ll index = 0;
	for(ll i = 0;i < N;i++){
		if(ans[i] >= maximum){
			maximum = ans[i];
			index = i;
		}
	}
	cout<<index<<'\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 316 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 2 ms 320 KB Output is correct
11 Correct 3 ms 340 KB Output is correct
12 Correct 2 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 320 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 4 ms 552 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 10 ms 596 KB Output is correct
18 Incorrect 3 ms 468 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 316 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 316 KB Output is correct
16 Correct 2 ms 340 KB Output is correct
17 Correct 2 ms 320 KB Output is correct
18 Correct 3 ms 340 KB Output is correct
19 Correct 2 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 3 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 4 ms 340 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 1 ms 316 KB Output is correct
28 Correct 3 ms 340 KB Output is correct
29 Correct 4 ms 552 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 10 ms 596 KB Output is correct
32 Incorrect 3 ms 468 KB Output isn't correct
33 Halted 0 ms 0 KB -