#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 time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8448 KB |
Output is correct |
2 |
Correct |
6 ms |
8448 KB |
Output is correct |
3 |
Correct |
5 ms |
8448 KB |
Output is correct |
4 |
Correct |
5 ms |
8448 KB |
Output is correct |
5 |
Correct |
5 ms |
8448 KB |
Output is correct |
6 |
Correct |
5 ms |
8448 KB |
Output is correct |
7 |
Incorrect |
5 ms |
8448 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8448 KB |
Output is correct |
2 |
Correct |
6 ms |
8448 KB |
Output is correct |
3 |
Correct |
5 ms |
8448 KB |
Output is correct |
4 |
Correct |
5 ms |
8448 KB |
Output is correct |
5 |
Correct |
5 ms |
8448 KB |
Output is correct |
6 |
Correct |
5 ms |
8448 KB |
Output is correct |
7 |
Incorrect |
5 ms |
8448 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
131 ms |
15864 KB |
Output is correct |
2 |
Correct |
132 ms |
15820 KB |
Output is correct |
3 |
Correct |
126 ms |
14200 KB |
Output is correct |
4 |
Correct |
139 ms |
15984 KB |
Output is correct |
5 |
Correct |
125 ms |
14584 KB |
Output is correct |
6 |
Correct |
129 ms |
14584 KB |
Output is correct |
7 |
Correct |
131 ms |
14200 KB |
Output is correct |
8 |
Correct |
127 ms |
14456 KB |
Output is correct |
9 |
Correct |
128 ms |
13876 KB |
Output is correct |
10 |
Correct |
127 ms |
14328 KB |
Output is correct |
11 |
Correct |
114 ms |
13416 KB |
Output is correct |
12 |
Correct |
102 ms |
13304 KB |
Output is correct |
13 |
Correct |
97 ms |
13304 KB |
Output is correct |
14 |
Correct |
92 ms |
13304 KB |
Output is correct |
15 |
Correct |
88 ms |
12528 KB |
Output is correct |
16 |
Correct |
71 ms |
12408 KB |
Output is correct |
17 |
Correct |
6 ms |
9216 KB |
Output is correct |
18 |
Correct |
6 ms |
9216 KB |
Output is correct |
19 |
Correct |
9 ms |
9216 KB |
Output is correct |
20 |
Correct |
8 ms |
9264 KB |
Output is correct |
21 |
Correct |
6 ms |
9216 KB |
Output is correct |
22 |
Correct |
6 ms |
9216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
8576 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
124 ms |
13344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
8500 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
13432 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8448 KB |
Output is correct |
2 |
Correct |
6 ms |
8448 KB |
Output is correct |
3 |
Correct |
5 ms |
8448 KB |
Output is correct |
4 |
Correct |
5 ms |
8448 KB |
Output is correct |
5 |
Correct |
5 ms |
8448 KB |
Output is correct |
6 |
Correct |
5 ms |
8448 KB |
Output is correct |
7 |
Incorrect |
5 ms |
8448 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
8448 KB |
Output is correct |
2 |
Correct |
6 ms |
8448 KB |
Output is correct |
3 |
Correct |
5 ms |
8448 KB |
Output is correct |
4 |
Correct |
5 ms |
8448 KB |
Output is correct |
5 |
Correct |
5 ms |
8448 KB |
Output is correct |
6 |
Correct |
5 ms |
8448 KB |
Output is correct |
7 |
Incorrect |
5 ms |
8448 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |