# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
426619 | TLP39 | Hotspot (NOI17_hotspot) | C++14 | 1076 ms | 1180 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,pair<int,int>> pii;
int n,m,k;
vector<int> adj[5003];
int shortest_path[2][5003];
int num_shortest_path[2][5003];
bool marked[2][5003];
double final[5003];
void bfs(int a,int pos)
{
for(int i=0;i<n;i++)
{
marked[pos][i]=false;
shortest_path[pos][i]=1000000;
num_shortest_path[pos][i]=0;
}
queue<int> q;
int temp;
q.push(a);
marked[pos][a]=true;
shortest_path[pos][a]=0;
num_shortest_path[pos][a]=1;
while(!q.empty())
{
temp=q.front();
q.pop();
for(int i=0;i<adj[temp].size();i++)
{
if(shortest_path[pos][adj[temp][i]]<=shortest_path[pos][temp]) continue;
if(!marked[pos][adj[temp][i]])
{
marked[pos][adj[temp][i]]=true;
shortest_path[pos][adj[temp][i]]=shortest_path[pos][temp]+1;
q.push(adj[temp][i]);
}
num_shortest_path[pos][adj[temp][i]]+=num_shortest_path[pos][temp];
}
}
}
int main()
{
scanf("%d %d",&n,&m);
int u,v;
for(int i=0;i<m;i++)
{
scanf("%d %d",&u,&v);
adj[u].push_back(v);
adj[v].push_back(u);
}
for(int i=0;i<n;i++) final[i]=(double)0;
scanf("%d",&k);
while(k--)
{
scanf("%d %d",&u,&v);
bfs(u,0);
bfs(v,1);
for(int i=0;i<n;i++)
{
if(shortest_path[0][v]!=shortest_path[0][i]+shortest_path[1][i]) continue;
final[i]+=((double)(num_shortest_path[0][i]*num_shortest_path[1][i]))/((double)(num_shortest_path[0][v]));
}
}
double maxi=(double)(-1);
int posi=-1;
for(int i=0;i<n;i++)
{
if(final[i]>maxi)
{
maxi=final[i];
posi=i;
}
}
printf("%d",posi);
}
컴파일 시 표준 에러 (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... |