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>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC taget("avx2,popcnt")
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
#define ld long double
const int mxn = 5050;
int N,M;
vector<int> paths[mxn];
long double dp[mxn];
struct BFS_GRAPH{
int s;
int c[mxn],d[mxn];
void set_s(int ss = 0){
s = ss;
}
void GO(){
memset(c,0,sizeof(c));
memset(d,-1,sizeof(d));
queue<int> q;
c[s] = 1;d[s] = 0;
q.push(s);
while(!q.empty()){
auto now = q.front();
q.pop();
for(auto nxt:paths[now]){
if(d[nxt] == -1){
d[nxt] = d[now]+1;
q.push(nxt);
}
if(d[nxt] == d[now]+1)c[nxt] += c[now];
}
}
return;
}
};
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 0;i<M;i++){
int a,b;
cin>>a>>b;
paths[a].push_back(b);
paths[b].push_back(a);
}
int Q;
cin>>Q;
while(Q--){
int s,e;
cin>>s>>e;
BFS_GRAPH g,rg;
g.s = s,rg.s = e;
g.GO();rg.GO();
int total = g.c[e];
for(int i = 0;i<N;i++){
if(g.d[i]+rg.d[i] != g.d[e])continue;
dp[i] += g.c[i]*rg.c[i]/(ld)total;
}
}
cout<<max_element(dp,dp+N)-dp;
}
Compilation message (stderr)
hotspot.cpp:4: warning: ignoring '#pragma GCC taget' [-Wunknown-pragmas]
4 | #pragma GCC taget("avx2,popcnt")
|
# | 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... |