Submission #430171

#TimeUsernameProblemLanguageResultExecution timeMemory
430171Ruba_KDuathlon (APIO18_duathlon)C++14
10 / 100
33 ms9932 KiB
#include<bits/stdc++.h> /* Created By Tornado2004 */ using namespace std; #define debug(x) cout << '[' << #x << " is: " << x << "] " << endl; #define imod(a , n) (a % n + n ) % n #define fastio ios_base::sync_with_stdio(false);cin.tie(0); #define inF freopen("wormsort.in","r",stdin ); #define outF freopen("wormsort.out" , "w" , stdout ) ; #define sor(v) sort(v.begin() , v.end()); #define print(v) for(auto f : v ) cout << f << " " ; #define rsor(v) sort(v.rbegin() , v.rend()); #define rev(v) reverse(v.begin() , v.end()); #define scan(v)for(auto &it : v)cin >> it ; #define ll long long //#define int ll #define logar(x , y) log(x) / log(y) #define __sum(n) n * (n + 1) / 2 #define __lcm(a , b) a / __gcd(a , b) * b #define pii pair<int , int > const int N = 2e5 + 3 , K = 11 , M = N * 4 ; const ll MOD = 998244353 , oo = 1e9 , OO = 1e18 , mod = MOD ; const double pi = acos(-1) , eps = 1e-17 ; //37 // (a ^ b / c ) % mod = (a ^ b ) % MOD * (c ^ (mod - 2)) % mod // m is prime --> (a ^ m) % m = a % m vector<int> adj[N]; int mat[1001][1001]; int vis[N] , vid ; ll ans ; ll dfs(int u , ll d ){ vis[u] = vid ; ll c = 1 ; for(auto f : adj[u]){ if(vis[f] != vid){ c += dfs(f , d + 1); } } ans += c - 1 ; return c ; } int32_t main() { //inF; //i bnF;outF; fastio; int n , m ; cin >> n >> m ; for(int i = 0 ; i < m ; i ++){ int a , b; cin >>a >> b; mat[a][b] = mat[b][a] = 1 ; adj[a].push_back(b); adj[b].push_back(a); } if(n < 3)cout << 0 ; else { for(int i = 1 ; i <= n ; i ++) for(int j = 1 ; j <= n ; j ++){ if(mat[i][j]){ vid ++ ; vis[i] = vid , vis[j] = vid ; dfs(j , 1); } //debug(ans) } cout << ans ; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...