Submission #262361

# Submission time Handle Problem Language Result Execution time Memory
262361 2020-08-12T17:08:52 Z CaroLinda Duathlon (APIO18_duathlon) C++14
0 / 100
84 ms 12152 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 ;
int sub[MAXN] ;
ll resp ;
bool vis[MAXN] ;
vector<int> adj[MAXN] ;

void dfs(int x)
{
    vis[x] = true ;
    sub[x] = 1 ;

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

    ll tot = (ll)(sub[x] - 1 ) ;

    resp += (tot*(tot-1)) ;

}

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) ;

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

}

Compilation message

count_triplets.cpp: In function 'int main()':
count_triplets.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |     scanf("%d%d", &N , &M ) ;
      |     ~~~~~^~~~~~~~~~~~~~~~~~
count_triplets.cpp:48:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |         scanf("%d%d", &u, &v ) ;
      |         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 12152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 7676 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 7672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -