Submission #138763

#TimeUsernameProblemLanguageResultExecution timeMemory
138763FedericoSDuathlon (APIO18_duathlon)C++14
0 / 100
212 ms13720 KiB
#include <iostream> #include <vector> using namespace std; typedef long long int ll; ll N,M; ll x,y; ll P,ans; bool V[100005]; vector<ll> grafo[300005]; void DFS(int k){ if(V[k]) return; P++; V[k]=true; for(int f:grafo[k]) DFS(f); } int main(){ cin>>N>>M; for(int i=0;i<M;i++){ cin>>x>>y; grafo[x].push_back(y); grafo[y].push_back(x); } for(int i=1;i<N+1;i++) if(!V[i]){ P=0; DFS(i); ans+=(P*(P-1)*(P-2))/3; } 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...