제출 #138770

#제출 시각아이디문제언어결과실행 시간메모리
138770FedericoS철인 이종 경기 (APIO18_duathlon)C++14
8 / 100
168 ms14948 KiB
#include <iostream> #include <vector> using namespace std; typedef long long int ll; ll N,M; ll x,y; ll A,B,ans; bool V[300005]; vector<ll> grafo[300005]; void DFS(int k){ B++; if(V[k]) return; A++; 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]){ A=B=0; DFS(i); if(B-1==2*A) ans+=(A*(A-1)*(A-2)); else ans+=(A*(A-1)*(A-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...