# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
103230 | 2019-03-29T09:08:04 Z | E869120 | 철인 이종 경기 (APIO18_duathlon) | C++14 | 213 ms | 11768 KB |
#include <iostream> #include <vector> using namespace std; #pragma warning (disable: 4996) long long N, M, A[200009], B[200009], col[100009], cnt1, cnt2; vector<int>X[100009]; void dfs(int pos) { if (col[pos] >= 1) return; col[pos] = 1; cnt1 += 1; cnt2 += X[pos].size(); for (int i = 0; i < X[pos].size(); i++) { dfs(X[pos][i]); } } int main() { scanf("%lld%lld", &N, &M); for (int i = 1; i <= M; i++) { scanf("%lld%lld", &A[i], &B[i]); X[A[i]].push_back(B[i]); X[B[i]].push_back(A[i]); } long long ans = 0; for (int i = 1; i <= N; i++) { if (col[i] >= 1) continue; cnt1 = 0; cnt2 = 0; dfs(i); cnt2 /= 2; if (cnt1 == cnt2) ans += 1LL * cnt1 * (cnt1 - 1) * (cnt1 - 2); else ans += 1LL * cnt1 * (cnt1 - 1) * (cnt1 - 2) / 3LL; } printf("%lld\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 11320 KB | Output is correct |
2 | Correct | 131 ms | 11256 KB | Output is correct |
3 | Correct | 149 ms | 9756 KB | Output is correct |
4 | Correct | 163 ms | 11768 KB | Output is correct |
5 | Correct | 126 ms | 10596 KB | Output is correct |
6 | Correct | 132 ms | 10464 KB | Output is correct |
7 | Correct | 115 ms | 10124 KB | Output is correct |
8 | Correct | 120 ms | 10332 KB | Output is correct |
9 | Correct | 213 ms | 9720 KB | Output is correct |
10 | Correct | 118 ms | 9976 KB | Output is correct |
11 | Correct | 109 ms | 9080 KB | Output is correct |
12 | Correct | 100 ms | 8952 KB | Output is correct |
13 | Correct | 104 ms | 8692 KB | Output is correct |
14 | Correct | 86 ms | 8440 KB | Output is correct |
15 | Correct | 68 ms | 7584 KB | Output is correct |
16 | Correct | 69 ms | 7544 KB | Output is correct |
17 | Correct | 11 ms | 3456 KB | Output is correct |
18 | Correct | 6 ms | 3456 KB | Output is correct |
19 | Correct | 7 ms | 3456 KB | Output is correct |
20 | Correct | 7 ms | 3456 KB | Output is correct |
21 | Correct | 7 ms | 3328 KB | Output is correct |
22 | Correct | 7 ms | 3456 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 2816 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 94 ms | 8336 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 5 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 130 ms | 8304 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |