#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=0;i<N;i++)
if(!V[i]){
P=0;
DFS(i);
ans+=(P*(P-1)*(P-2))/3;
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
210 ms |
14988 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
173 ms |
12464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
7416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
189 ms |
12460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
7288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |