This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
if(M==N)
cout<<(N*(N-1)*(N-2));
else
cout<<(N*(N-1)*(N-2))/3;
/*
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |