# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105451 | hainam2k9 | Hotspot (NOI17_hotspot) | C++17 | 43 ms | 196520 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "TRAINCENTRE";
int n,m,k,x,y;
vector<int> adj[5005];
pair<int,int> dist[5005][5005],p[2005];
pair<int,db> rs;
int main()
{
tt;
if(fopen((NAME + ".INP").c_str(), "r")) fo;
cin >> n >> m;
for(int i = 1; i<=m; ++i)
cin >> x >> y, ++x, ++y, adj[x].pb(y), adj[y].pb(x);
memset(dist,0x3f,sizeof(dist));
for(int i = 1; i<=n; ++i){
queue<int> q;
q.push(i), dist[i][i].fi=0, dist[i][i].se=1;
while(!q.empty()){
int u = q.front();
for(int v : adj[u]){
if(dist[i][v].fi>dist[i][u].fi+1) dist[i][v].fi=dist[i][u].fi+1, dist[i][v].se=dist[i][u].se, q.push(v);
else if(dist[i][v].fi==dist[i][u].fi+1) dist[i][v].se+=dist[i][u].se;
}
q.pop();
}
}
cin >> k;
for(int i = 1; i<=k; ++i)
cin >> p[i].fi >> p[i].se, ++p[i].fi, ++p[i].se;
for(int i = 1; i<=n; ++i){
db e=0;
for(int j = 1; j<=k; ++j){
if(dist[i][p[j].fi].fi+dist[i][p[j].se].fi>dist[p[j].fi][p[j].se].fi) continue;
e+=1.0L*dist[p[j].fi][i].se*dist[p[j].se][i].se/dist[p[i].fi][p[i].se].se;
}
if(e>rs.se) rs.fi=i, rs.se=e;
}
cout << rs.fi+1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |