답안 #103542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
103542 2019-03-31T11:32:56 Z Hideo 철인 이종 경기 (APIO18_duathlon) C++14
0 / 100
162 ms 8744 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define vi vector < int >
#define pii pair < int, int >

const int N = 2e5 + 7;
const int INF = 1e9 + 7;

int sz[N];
int n, m;
ll ans;

vi g[N];

void dfs (int v = 1, int p = 0){
    sz[v] = 1;
    for (int to : g[v]){
        if (to != p){
            dfs(to, v);
            sz[v] += sz[to];
        }
    }

}

main(){
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    if (m == n - 1){
        dfs();
        for (int i = 1; i <= n; i++){
            ans += sz[i] * (n - sz[i]);
        }
        cout << (ll) ans * 2 - n * (n - 1);
    }
    else {
        cout << 0;
    }
}

Compilation message

count_triplets.cpp:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 133 ms 8312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 5120 KB Output is correct
2 Correct 8 ms 5120 KB Output is correct
3 Correct 7 ms 4992 KB Output is correct
4 Correct 8 ms 5120 KB Output is correct
5 Correct 7 ms 5120 KB Output is correct
6 Correct 7 ms 5120 KB Output is correct
7 Correct 7 ms 5120 KB Output is correct
8 Correct 6 ms 4992 KB Output is correct
9 Correct 8 ms 5120 KB Output is correct
10 Incorrect 7 ms 4992 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 162 ms 8688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 5120 KB Output is correct
2 Correct 7 ms 5120 KB Output is correct
3 Incorrect 7 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 140 ms 8744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -