Submission #928192

#TimeUsernameProblemLanguageResultExecution timeMemory
928192panHotspot (NOI17_hotspot)C++17
38 / 100
53 ms14288 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...