Submission #252700

#TimeUsernameProblemLanguageResultExecution timeMemory
252700SugardorjDuathlon (APIO18_duathlon)C++14
8 / 100
140 ms15984 KiB
#include <bits/stdc++.h> using namespace std; long long b[323567],c[323456],a[323456],tt,d[334564],e[456744]; long long x,m,n,t,k,l; long long i , j,r,s,y,z; vector <long long> p[345678],q; void dfs(long long x){ c[x] = 1; t++; if (p[x].size()==1) y=1; for(auto u:p[x]){ if (c[u]) continue; dfs(u); } } int main(){ cin >> n>>m; for (i = 0; i<m; i ++){ cin >> x>>y; p[x].push_back(y); p[y].push_back(x); } s=0; for (i = 1; i <=n; i ++){ if (c[i]) continue; t=0; y=0; dfs(i); l = t*(t-1)*(t-2); if (y==1) l/=3; s+=l; } cout << s; }
#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...