#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;
const int MAXN = 1e5 + 7;
vector<int> edges[MAXN];
bool done[MAXN],ok;
ll ans,cur;
void dfs(int c)
{
done[c]=1;
++cur;
if (sz(edges[c])<2)
ok=0;
for (int i : edges[c])
if (!done[i])
dfs(i);
}
int main()
{
int n,m,u,v;
cin>>n>>m;
while (m--)
{
cin>>u>>v;
edges[u].push_back(v);
edges[v].push_back(u);
}
for (int i=1;i<=n;++i)
if (!done[i])
{
cur=0;
ok=1;
dfs(i);
if (ok)
ans+=((cur)*(cur-1)*(cur-2));
else
ans+=(((cur)*(cur-1)*(cur-2))/3);
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2688 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2688 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
172 ms |
10232 KB |
Output is correct |
2 |
Correct |
186 ms |
10236 KB |
Output is correct |
3 |
Correct |
166 ms |
8696 KB |
Output is correct |
4 |
Correct |
168 ms |
9464 KB |
Output is correct |
5 |
Correct |
166 ms |
8184 KB |
Output is correct |
6 |
Correct |
169 ms |
8184 KB |
Output is correct |
7 |
Correct |
163 ms |
7800 KB |
Output is correct |
8 |
Correct |
165 ms |
8056 KB |
Output is correct |
9 |
Correct |
165 ms |
7524 KB |
Output is correct |
10 |
Correct |
165 ms |
7676 KB |
Output is correct |
11 |
Correct |
140 ms |
6964 KB |
Output is correct |
12 |
Correct |
135 ms |
6776 KB |
Output is correct |
13 |
Correct |
121 ms |
6776 KB |
Output is correct |
14 |
Correct |
120 ms |
6520 KB |
Output is correct |
15 |
Correct |
91 ms |
6136 KB |
Output is correct |
16 |
Correct |
89 ms |
5884 KB |
Output is correct |
17 |
Correct |
3 ms |
2720 KB |
Output is correct |
18 |
Correct |
3 ms |
2816 KB |
Output is correct |
19 |
Correct |
3 ms |
2816 KB |
Output is correct |
20 |
Correct |
3 ms |
2816 KB |
Output is correct |
21 |
Correct |
3 ms |
2816 KB |
Output is correct |
22 |
Correct |
3 ms |
2816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
158 ms |
7288 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
2688 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
162 ms |
7280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2688 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
2688 KB |
Output is correct |
2 |
Correct |
2 ms |
2688 KB |
Output is correct |
3 |
Correct |
2 ms |
2688 KB |
Output is correct |
4 |
Correct |
2 ms |
2688 KB |
Output is correct |
5 |
Correct |
2 ms |
2688 KB |
Output is correct |
6 |
Correct |
2 ms |
2688 KB |
Output is correct |
7 |
Incorrect |
2 ms |
2688 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |