# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
731824 |
2023-04-28T04:03:22 Z |
Trunkty |
Hotspot (NOI17_hotspot) |
C++14 |
|
1178 ms |
277648 KB |
#include <bits/extc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n,m,q;
vector<int> roads[5005];
int best[5005][5005],cnt[5005][5005];
long double val[5005];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
for(int i=1;i<=m;i++){
int a,b;
cin >> a >> b;
roads[a].push_back(b);
roads[b].push_back(a);
}
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
best[i][j] = 2000000000;
}
vector<int> v = {i};
best[i][i] = 0;
cnt[i][i] = 1;
for(int j=0;j<v.size();j++){
int x = v[j];
for(int k:roads[x]){
if(best[i][k]==best[i][x]+1){
cnt[i][k] += cnt[i][x];
}
else if(best[i][k]>best[i][x]+1){
best[i][k] = best[i][x]+1;
cnt[i][k] = cnt[i][x];
v.push_back(k);
}
}
}
}
cin >> q;
for(int i=1;i<=q;i++){
int a,b;
cin >> a >> b;
for(int j=1;j<=n;j++){
if(best[a][j]+best[b][j]==best[a][b]){
long double p = cnt[a][j]*cnt[b][j];
long double q = cnt[a][b];
val[j] += p/q;
}
}
}
vector<pair<long double,int>> v;
for(int i=1;i<=n;i++){
v.push_back({val[i],i});
}
sort(v.begin(),v.end(),greater<pair<long double,int>>());
cout << v[0].second << "\n";
return 0;
}
Compilation message
hotspot.cpp: In function 'int main()':
hotspot.cpp:28:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int j=0;j<v.size();j++){
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
8 |
Correct |
3 ms |
3412 KB |
Output is correct |
9 |
Correct |
10 ms |
9300 KB |
Output is correct |
10 |
Correct |
21 ms |
17648 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
4 ms |
4692 KB |
Output is correct |
14 |
Correct |
15 ms |
11268 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
8 |
Correct |
6 ms |
4820 KB |
Output is correct |
9 |
Correct |
13 ms |
11460 KB |
Output is correct |
10 |
Correct |
10 ms |
9764 KB |
Output is correct |
11 |
Correct |
22 ms |
18156 KB |
Output is correct |
12 |
Correct |
2 ms |
1604 KB |
Output is correct |
13 |
Correct |
1 ms |
852 KB |
Output is correct |
14 |
Correct |
5 ms |
5076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
8 |
Correct |
3 ms |
3412 KB |
Output is correct |
9 |
Correct |
10 ms |
9300 KB |
Output is correct |
10 |
Correct |
21 ms |
17648 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
4 ms |
4692 KB |
Output is correct |
14 |
Correct |
15 ms |
11268 KB |
Output is correct |
15 |
Correct |
6 ms |
4820 KB |
Output is correct |
16 |
Correct |
13 ms |
11460 KB |
Output is correct |
17 |
Correct |
10 ms |
9764 KB |
Output is correct |
18 |
Correct |
22 ms |
18156 KB |
Output is correct |
19 |
Correct |
2 ms |
1604 KB |
Output is correct |
20 |
Correct |
1 ms |
852 KB |
Output is correct |
21 |
Correct |
5 ms |
5076 KB |
Output is correct |
22 |
Correct |
7 ms |
6460 KB |
Output is correct |
23 |
Correct |
5 ms |
5184 KB |
Output is correct |
24 |
Correct |
16 ms |
11932 KB |
Output is correct |
25 |
Correct |
29 ms |
21232 KB |
Output is correct |
26 |
Correct |
25 ms |
18764 KB |
Output is correct |
27 |
Correct |
2 ms |
1856 KB |
Output is correct |
28 |
Correct |
8 ms |
6748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
8 |
Correct |
3 ms |
3412 KB |
Output is correct |
9 |
Correct |
10 ms |
9300 KB |
Output is correct |
10 |
Correct |
21 ms |
17648 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
4 ms |
4692 KB |
Output is correct |
14 |
Correct |
15 ms |
11268 KB |
Output is correct |
15 |
Correct |
11 ms |
2100 KB |
Output is correct |
16 |
Correct |
18 ms |
6868 KB |
Output is correct |
17 |
Correct |
59 ms |
14504 KB |
Output is correct |
18 |
Correct |
27 ms |
12424 KB |
Output is correct |
19 |
Correct |
65 ms |
21884 KB |
Output is correct |
20 |
Correct |
10 ms |
3156 KB |
Output is correct |
21 |
Correct |
4 ms |
2132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
8928 KB |
Output is correct |
2 |
Correct |
20 ms |
17236 KB |
Output is correct |
3 |
Correct |
16 ms |
15048 KB |
Output is correct |
4 |
Correct |
1 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
4436 KB |
Output is correct |
6 |
Correct |
3 ms |
3284 KB |
Output is correct |
7 |
Correct |
10 ms |
9152 KB |
Output is correct |
8 |
Correct |
3 ms |
3412 KB |
Output is correct |
9 |
Correct |
10 ms |
9300 KB |
Output is correct |
10 |
Correct |
21 ms |
17648 KB |
Output is correct |
11 |
Correct |
1 ms |
1492 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
4 ms |
4692 KB |
Output is correct |
14 |
Correct |
15 ms |
11268 KB |
Output is correct |
15 |
Correct |
6 ms |
4820 KB |
Output is correct |
16 |
Correct |
13 ms |
11460 KB |
Output is correct |
17 |
Correct |
10 ms |
9764 KB |
Output is correct |
18 |
Correct |
22 ms |
18156 KB |
Output is correct |
19 |
Correct |
2 ms |
1604 KB |
Output is correct |
20 |
Correct |
1 ms |
852 KB |
Output is correct |
21 |
Correct |
5 ms |
5076 KB |
Output is correct |
22 |
Correct |
7 ms |
6460 KB |
Output is correct |
23 |
Correct |
5 ms |
5184 KB |
Output is correct |
24 |
Correct |
16 ms |
11932 KB |
Output is correct |
25 |
Correct |
29 ms |
21232 KB |
Output is correct |
26 |
Correct |
25 ms |
18764 KB |
Output is correct |
27 |
Correct |
2 ms |
1856 KB |
Output is correct |
28 |
Correct |
8 ms |
6748 KB |
Output is correct |
29 |
Correct |
11 ms |
2100 KB |
Output is correct |
30 |
Correct |
18 ms |
6868 KB |
Output is correct |
31 |
Correct |
59 ms |
14504 KB |
Output is correct |
32 |
Correct |
27 ms |
12424 KB |
Output is correct |
33 |
Correct |
65 ms |
21884 KB |
Output is correct |
34 |
Correct |
10 ms |
3156 KB |
Output is correct |
35 |
Correct |
4 ms |
2132 KB |
Output is correct |
36 |
Correct |
25 ms |
3352 KB |
Output is correct |
37 |
Correct |
138 ms |
31388 KB |
Output is correct |
38 |
Correct |
1178 ms |
215152 KB |
Output is correct |
39 |
Correct |
110 ms |
15820 KB |
Output is correct |
40 |
Correct |
494 ms |
167780 KB |
Output is correct |
41 |
Correct |
1153 ms |
277648 KB |
Output is correct |
42 |
Correct |
237 ms |
35556 KB |
Output is correct |
43 |
Correct |
200 ms |
79696 KB |
Output is correct |
44 |
Correct |
197 ms |
79680 KB |
Output is correct |