# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
90861 | daniel_02 | 관광지 (IZhO14_shymbulak) | C++17 | 1569 ms | 11476 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define pb push_back
#define sc second
#define ll long long
using namespace std;
const int N = 2e5 + 7;
const int inf = 1e6 + 7;
vector<int>g[N];
int d[N];
int cn[N];
queue<pair<int, int>>q;
void mems(){
for (int i = 0; i < N; i++)
d[i] = inf;
queue<pair<int, int>>empty;
swap(q, empty);
}
void dance(int a)
{
mems();
q.push({a, 0});
d[a] = 0;
while (!q.empty())
{
int v = q.front().fr, cs = q.front().sc;
q.pop();
if (cs > d[v])continue;
for (int i = 0; i < g[v].size(); i++)
{
int to = g[v][i];
if (cs + 1 <= d[to])
{
d[to] = cs + 1;
cn[d[to]]++;
q.push({to, d[to]});
}
}
}
}
main()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
int a, b;
scanf("%d%d", &a, &b);
g[a].pb(b);
g[b].pb(a);
}
int mx = 0;
for (int i = 1; i <= n; i++)
{
dance(i);
for (int j = 1; j <= n; j++)
{
if (i == j)continue;
mx = max(mx, d[j]);
}
}
cout << cn[mx] / 2 << endl;
}
컴파일 시 표준 에러 (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... |