# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
928196 |
2024-02-16T04:21:56 Z |
pan |
Hotspot (NOI17_hotspot) |
C++17 |
|
1133 ms |
245920 KB |
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include "bits_stdc++.h"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
using namespace std;
//using namespace __gnu_pbds;
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<ll, pi> pii;
ll const INF = 1e13;
ll n, m, x, y, k;
vector<ll> adj[5005];
ld e[5005] = {0.0};
vector<vector<pi> > dist;
void bfs(ll from)
{
vector<pi>& now = dist[from];
now.assign(n, mp(INF, 1));
vector<bool> visited(n, false);
now[from] = mp(0, 1);
deque<ll> nxt;
nxt.pb(from);
while (nxt.size())
{
ll c = nxt.front();
nxt.pop_front();
if (visited[c]) continue;
visited[c] = 1;
for (ll u: adj[c])
{
if (now[u].f>now[c].f+1)
{
now[u] = mp(now[c].f+1, now[c].s);
nxt.pb(u);
}
else if (now[u].f==now[c].f+1)
{
now[u].s+=now[c].s;
}
}
}
}
int main()
{
input(n); input(m);
dist.resize(n);
for (ll i=0; i<m; ++i)
{
input2(x,y);
adj[x].pb(y);
adj[y].pb(x);
}
for (ll i=0; i<n; ++i) bfs(i);
input(k);
while (k--)
{
input2(x, y);
ll total = dist[x][y].s;
ll len = dist[x][y].f;
vector<ll> way(n, 0);
for (ll i=0; i<n; ++i) if (dist[x][i].f + dist[i][y].f==len) way[i]+= (dist[x][i].s*dist[i][y].s);
for (ll i=0; i<n; ++i) e[i]+= ld((ld)way[i]/(ld)total);
}
cout << max_element(e, e+n)-e << endl;
return 0;
}
Compilation message
hotspot.cpp: In function 'int main()':
hotspot.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
hotspot.cpp:68:2: note: in expansion of macro 'input'
68 | input(n); input(m);
| ^~~~~
hotspot.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
hotspot.cpp:68:12: note: in expansion of macro 'input'
68 | input(n); input(m);
| ^~~~~
hotspot.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define input2(x, y) scanf("%lld%lld", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
hotspot.cpp:72:3: note: in expansion of macro 'input2'
72 | input2(x,y);
| ^~~~~~
hotspot.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
hotspot.cpp:77:2: note: in expansion of macro 'input'
77 | input(k);
| ^~~~~
hotspot.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define input2(x, y) scanf("%lld%lld", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
hotspot.cpp:80:3: note: in expansion of macro 'input2'
80 | input2(x, y);
| ^~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
5 ms |
4956 KB |
Output is correct |
10 |
Correct |
11 ms |
11100 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
2140 KB |
Output is correct |
14 |
Correct |
6 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
8 |
Correct |
2 ms |
2140 KB |
Output is correct |
9 |
Correct |
6 ms |
6740 KB |
Output is correct |
10 |
Correct |
6 ms |
5208 KB |
Output is correct |
11 |
Correct |
11 ms |
11356 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
604 KB |
Output is correct |
14 |
Correct |
2 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
5 ms |
4956 KB |
Output is correct |
10 |
Correct |
11 ms |
11100 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
2140 KB |
Output is correct |
14 |
Correct |
6 ms |
6236 KB |
Output is correct |
15 |
Correct |
2 ms |
2140 KB |
Output is correct |
16 |
Correct |
6 ms |
6740 KB |
Output is correct |
17 |
Correct |
6 ms |
5208 KB |
Output is correct |
18 |
Correct |
11 ms |
11356 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
3 ms |
3160 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
7 ms |
6772 KB |
Output is correct |
25 |
Correct |
15 ms |
13660 KB |
Output is correct |
26 |
Correct |
13 ms |
11872 KB |
Output is correct |
27 |
Correct |
1 ms |
1096 KB |
Output is correct |
28 |
Correct |
4 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
5 ms |
4956 KB |
Output is correct |
10 |
Correct |
11 ms |
11100 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
2140 KB |
Output is correct |
14 |
Correct |
6 ms |
6236 KB |
Output is correct |
15 |
Correct |
9 ms |
856 KB |
Output is correct |
16 |
Correct |
11 ms |
3416 KB |
Output is correct |
17 |
Correct |
40 ms |
8580 KB |
Output is correct |
18 |
Correct |
21 ms |
7256 KB |
Output is correct |
19 |
Correct |
53 ms |
14420 KB |
Output is correct |
20 |
Correct |
7 ms |
1620 KB |
Output is correct |
21 |
Correct |
2 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4696 KB |
Output is correct |
2 |
Correct |
9 ms |
10588 KB |
Output is correct |
3 |
Correct |
8 ms |
9160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
2036 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
4 ms |
4956 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
5 ms |
4956 KB |
Output is correct |
10 |
Correct |
11 ms |
11100 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
2 ms |
2140 KB |
Output is correct |
14 |
Correct |
6 ms |
6236 KB |
Output is correct |
15 |
Correct |
2 ms |
2140 KB |
Output is correct |
16 |
Correct |
6 ms |
6740 KB |
Output is correct |
17 |
Correct |
6 ms |
5208 KB |
Output is correct |
18 |
Correct |
11 ms |
11356 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
604 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
3 ms |
3160 KB |
Output is correct |
23 |
Correct |
2 ms |
2396 KB |
Output is correct |
24 |
Correct |
7 ms |
6772 KB |
Output is correct |
25 |
Correct |
15 ms |
13660 KB |
Output is correct |
26 |
Correct |
13 ms |
11872 KB |
Output is correct |
27 |
Correct |
1 ms |
1096 KB |
Output is correct |
28 |
Correct |
4 ms |
3164 KB |
Output is correct |
29 |
Correct |
9 ms |
856 KB |
Output is correct |
30 |
Correct |
11 ms |
3416 KB |
Output is correct |
31 |
Correct |
40 ms |
8580 KB |
Output is correct |
32 |
Correct |
21 ms |
7256 KB |
Output is correct |
33 |
Correct |
53 ms |
14420 KB |
Output is correct |
34 |
Correct |
7 ms |
1620 KB |
Output is correct |
35 |
Correct |
2 ms |
860 KB |
Output is correct |
36 |
Correct |
23 ms |
1624 KB |
Output is correct |
37 |
Correct |
114 ms |
22064 KB |
Output is correct |
38 |
Correct |
1032 ms |
187440 KB |
Output is correct |
39 |
Correct |
108 ms |
9932 KB |
Output is correct |
40 |
Correct |
423 ms |
143440 KB |
Output is correct |
41 |
Correct |
1133 ms |
245920 KB |
Output is correct |
42 |
Correct |
239 ms |
25428 KB |
Output is correct |
43 |
Correct |
165 ms |
63568 KB |
Output is correct |
44 |
Correct |
160 ms |
63568 KB |
Output is correct |