Submission #928192

# Submission time Handle Problem Language Result Execution time Memory
928192 2024-02-16T04:04:14 Z pan Hotspot (NOI17_hotspot) C++17
38 / 100
53 ms 14288 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, 1);
				nxt.pb(u);
			}
			else if (now[u].f==now[c].f+1)
			{
				now[u].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);
	}
	ll ans = max_element(e, e+n)-e;
	print(ans, '\n');
	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 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
8 Correct 2 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 0 ms 560 KB Output is correct
13 Correct 2 ms 2164 KB Output is correct
14 Correct 6 ms 6236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
8 Correct 2 ms 2136 KB Output is correct
9 Correct 6 ms 6488 KB Output is correct
10 Correct 5 ms 5212 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 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
8 Correct 2 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 0 ms 560 KB Output is correct
13 Correct 2 ms 2164 KB Output is correct
14 Correct 6 ms 6236 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 6 ms 6488 KB Output is correct
17 Correct 5 ms 5212 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 3164 KB Output is correct
23 Correct 3 ms 2392 KB Output is correct
24 Correct 7 ms 6748 KB Output is correct
25 Correct 15 ms 13660 KB Output is correct
26 Correct 13 ms 11868 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 4 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
8 Correct 2 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 0 ms 560 KB Output is correct
13 Correct 2 ms 2164 KB Output is correct
14 Correct 6 ms 6236 KB Output is correct
15 Correct 8 ms 1112 KB Output is correct
16 Correct 11 ms 3420 KB Output is correct
17 Correct 39 ms 8628 KB Output is correct
18 Correct 21 ms 7260 KB Output is correct
19 Incorrect 53 ms 14288 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 4700 KB Output is correct
2 Correct 9 ms 10588 KB Output is correct
3 Correct 8 ms 9052 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 1884 KB Output is correct
6 Correct 1 ms 1372 KB Output is correct
7 Correct 4 ms 4912 KB Output is correct
8 Correct 2 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 0 ms 560 KB Output is correct
13 Correct 2 ms 2164 KB Output is correct
14 Correct 6 ms 6236 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 6 ms 6488 KB Output is correct
17 Correct 5 ms 5212 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 3164 KB Output is correct
23 Correct 3 ms 2392 KB Output is correct
24 Correct 7 ms 6748 KB Output is correct
25 Correct 15 ms 13660 KB Output is correct
26 Correct 13 ms 11868 KB Output is correct
27 Correct 1 ms 860 KB Output is correct
28 Correct 4 ms 3164 KB Output is correct
29 Correct 8 ms 1112 KB Output is correct
30 Correct 11 ms 3420 KB Output is correct
31 Correct 39 ms 8628 KB Output is correct
32 Correct 21 ms 7260 KB Output is correct
33 Incorrect 53 ms 14288 KB Output isn't correct
34 Halted 0 ms 0 KB -