# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
387951 | NurstanDuisengaliev | Duathlon (APIO18_duathlon) | C++14 | 64 ms | 12804 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int ll
using namespace std;
const int N = (int)1e5 + 123;
int n, m;
vector <int> g[N];
int used[N];
ll ans = 0, LEN = 0;
bool FindC (int v) {
used[v] = 1;
bool yes = 0;
LEN ++;
for (auto to : g[v]) {
if (!used[to]) {
yes |= FindC (to);
}
else if (used[to] == 1) {
yes = 1;
}
}
used[v] = 2;
return yes;
}
main () {
ios_base::sync_with_stdio (0);
cin >> n >> m;
for (int i = 1; i <= m; i ++) {
int u, v;
cin >> u >> v;
g[u].pb (v);
g[v].pb (u);
}
int maxisz = 0;
for (int i = 1; i <= n; i ++) {
maxisz = max (maxisz, sz (g[i]));
}
if (maxisz <= 2) {
for (int i = 1; i <= n; i ++) {
if (!used[i]) {
LEN = 0;
if (FindC (i)) {
ans += ((LEN * 1ll * (LEN - 1) * 1ll * (LEN - 2)) / 3);
}
else {
for (int j = 1; j <= LEN - 2; j ++) {
ans += (LEN - (j + 2) + 1) * 1ll * j;
}
}
}
}
cout << ans;
exit (0);
}
return 0;
}
컴파일 시 표준 에러 (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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |