链接

bzoj

思路

总方案\(C_{n}^{3}-异色三角形\)
异色三角形有个特点。
会出现两个点有两条不同色的边。
然后统计就行了。

代码

#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int _=5e3+7;
int n,m,a[_];
int main() {
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;++i) {
		scanf("%d%d",&u,&v);
		a[u]++,a[v]++;
	}
	ll tot=0,ans=1LL*n*(n-1)*(n-2)/6;
	for(int i=1;i<=n;++i) tot+=(n-a[i]-1)*a[i];
	ans-=tot/2;
	cout<<ans<<"\n";
	return 0;
}

相关文章:

  • 2021-07-06
  • 2021-08-29
  • 2022-02-26
  • 2022-01-22
  • 2021-09-17
  • 2021-09-05
  • 2021-05-16
  • 2022-02-09
猜你喜欢
  • 2021-06-01
  • 2022-01-22
  • 2021-05-24
  • 2021-11-25
  • 2022-01-10
  • 2021-11-12
  • 2021-08-05
相关资源
相似解决方案