답안 #262378

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262378 2020-08-12T18:06:24 Z CaroLinda 철인 이종 경기 (APIO18_duathlon) C++14
23 / 100
110 ms 12532 KB
#include <bits/stdc++.h>

#define lp(i,a,b) for(int i = a; i < b ; i++)
#define ff first
#define ss second
#define pb emplace_back
#define ll long long
#define mk make_pair
#define sz(x) x.size()
#define pii pair<int,int>
#define mkt make_tuple
#define debug

const int MAXN = 1e5+10 ;

using namespace std ;

int N , M ;
ll sub[MAXN] ;
ll resp ;
bool vis[MAXN] ;
vector<int> pilha ;
vector<int> adj[MAXN] ;

void dfs(int x)
{
    vis[x] = true ;
    sub[x] = 0LL ;
    pilha.emplace_back(x) ;

    for(auto y : adj[x] )
    {
        if(vis[y]) continue ;
        dfs(y) ;

        resp += sub[x] * sub[y] * 2LL ;
        sub[x] += sub[y] ;

    }

    sub[x]++ ;

}

int main()
{

    scanf("%d%d", &N , &M ) ;
    for(int i = 1 , u , v ; i <= M ; i++ )
    {
        scanf("%d%d", &u, &v ) ;
        adj[u].pb(v) ;
        adj[v].pb(u) ;
    }

    lp(i,1,N+1)
        if(!vis[i])
        {
            dfs(i) ;
            for(auto e : pilha ) resp += (sub[e]-1) * (sub[i] - sub[e] ) * 2LL ;
            pilha.clear() ; pilha.shrink_to_fit() ;
        }

    printf("%lld\n" , resp ) ;

}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |     scanf("%d%d", &N , &M ) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~
count_triplets.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   51 |         scanf("%d%d", &u, &v ) ;
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 12532 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Correct 2 ms 2688 KB Output is correct
4 Correct 2 ms 2816 KB Output is correct
5 Correct 3 ms 2688 KB Output is correct
6 Correct 3 ms 2688 KB Output is correct
7 Correct 3 ms 2732 KB Output is correct
8 Correct 3 ms 2688 KB Output is correct
9 Correct 3 ms 2688 KB Output is correct
10 Correct 2 ms 2688 KB Output is correct
11 Correct 3 ms 2688 KB Output is correct
12 Correct 3 ms 2816 KB Output is correct
13 Correct 2 ms 2688 KB Output is correct
14 Correct 2 ms 2688 KB Output is correct
15 Correct 3 ms 2688 KB Output is correct
16 Correct 2 ms 2688 KB Output is correct
17 Correct 2 ms 2688 KB Output is correct
18 Correct 2 ms 2688 KB Output is correct
19 Correct 2 ms 2688 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 8056 KB Output is correct
2 Correct 74 ms 8696 KB Output is correct
3 Correct 76 ms 8824 KB Output is correct
4 Correct 73 ms 8696 KB Output is correct
5 Correct 74 ms 8696 KB Output is correct
6 Correct 83 ms 11128 KB Output is correct
7 Correct 84 ms 10192 KB Output is correct
8 Correct 84 ms 9692 KB Output is correct
9 Correct 79 ms 9464 KB Output is correct
10 Correct 75 ms 8432 KB Output is correct
11 Correct 94 ms 8696 KB Output is correct
12 Correct 84 ms 8372 KB Output is correct
13 Correct 74 ms 8228 KB Output is correct
14 Correct 68 ms 7928 KB Output is correct
15 Correct 56 ms 7672 KB Output is correct
16 Correct 39 ms 6520 KB Output is correct
17 Correct 51 ms 9200 KB Output is correct
18 Correct 46 ms 8944 KB Output is correct
19 Correct 45 ms 8940 KB Output is correct
20 Correct 48 ms 8948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
3 Incorrect 2 ms 2688 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 8056 KB Output is correct
2 Correct 70 ms 8692 KB Output is correct
3 Incorrect 110 ms 8820 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -