답안 #106240

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106240 2019-04-17T15:58:42 Z Just_Solve_The_Problem 철인 이종 경기 (APIO18_duathlon) C++11
10 / 100
177 ms 13712 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];
int asd;
int as[N];
 
void dfs (int v = 1, int p = 0){
    sz[v] = 1;
    as[v] = asd;
    for (int to : g[v]){
        if (!sz[to]){
            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);
    }
    vector <int> root;
    for (int i = 1; i <= n; i++) {
			if (!sz[i]) {
				asd = i;
				dfs(i);
				ans -= sz[i] * (sz[i] - 1) / 2;
			}
    }
    for (int i = 1; i <= n; i++) {
			ans += (sz[i] * (sz[as[i]] - sz[i]));
    }
    cout << ans * 2;
}

Compilation message

count_triplets.cpp:35: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 147 ms 13712 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 4992 KB Output is correct
2 Correct 7 ms 5120 KB Output is correct
3 Correct 6 ms 5120 KB Output is correct
4 Correct 7 ms 4992 KB Output is correct
5 Correct 8 ms 5120 KB Output is correct
6 Correct 9 ms 5120 KB Output is correct
7 Correct 8 ms 5120 KB Output is correct
8 Correct 7 ms 5120 KB Output is correct
9 Correct 6 ms 5120 KB Output is correct
10 Correct 8 ms 5120 KB Output is correct
11 Correct 8 ms 5120 KB Output is correct
12 Correct 7 ms 5120 KB Output is correct
13 Correct 9 ms 5064 KB Output is correct
14 Correct 8 ms 5120 KB Output is correct
15 Correct 7 ms 5120 KB Output is correct
16 Correct 7 ms 4992 KB Output is correct
17 Correct 7 ms 4992 KB Output is correct
18 Correct 7 ms 4992 KB Output is correct
19 Correct 9 ms 5120 KB Output is correct
20 Correct 9 ms 5120 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 177 ms 9060 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 8 ms 4992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 127 ms 9080 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 -