90pts TLE求助
  • 板块灌水区
  • 楼主liuyi0905
  • 当前回复4
  • 已保存回复4
  • 发布时间2023/10/11 21:00
  • 上次更新2023/11/2 14:24:30
查看原帖
90pts TLE求助
717971
liuyi0905楼主2023/10/11 21:00

题目

代码:

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int t,n,a[N],b[N];
int work(){
	int t1[N]={0},t2[N]={0},C=n*(n-1)*(n-2)/6,B=0;
	for(int i=1;i<=n;i++)t1[a[i]]++,t2[b[i]]++;
	for(int i=1;i<=n;i++)B+=(t1[a[i]]-1)*(t2[b[i]]-1);
	return C-B;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--){
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
		cout<<work()<<"\n";
	}
	return 0;
}

求助哪写错了?

2023/10/11 21:00
加载中...