# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
37876 | Just_Solve_The_Problem | Shymbulak (IZhO14_shymbulak) | C++11 | 1500 ms | 8176 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
const int N = (int)1e5 + 7;
vector < int > gr[N];
int used[N];
int ans[N];
pair < int, int > otv;
void dfs (int v, int h = 0) {
used[v] = h;
ans[v] = 1;
for (int to : gr[v]) {
if (h + 1 < used[to]) {
dfs(to, h + 1);
} else if (h + 1 == used[to]) {
ans[to]++;
}
}
}
main () {
int n; scanf ("%d", &n);
for (int i = 1; i <= n; i++) {
int u, v; scanf ("%d %d", &u, &v);
gr[u].pb(v);
gr[v].pb(u);
}
pair < int, int > res;
res = {0, 0};
for (int i = 1; i <= n; i++) {
memset(used, 63, sizeof(used));
dfs(i);
for (int j = 1; j <= n; j++) {
if (used[j] > res.fr) {
res.fr = used[j];
res.sc = ans[j];
} else if (used[j] == res.fr) {
res.sc += ans[j];
}
}
}
cout << res.sc - 2;
}
컴파일 시 표준 에러 (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... |