32 2 41 11 22 12 23 1 31 12 13 13 3 31 12 12 2 Sample Output802已经AC过的代码:
#include<cstdio>#include<iostream>#include<vector>#include<cstring>using namespace std;long long d1[100010],d2[100010];struct edge{ int x,y;};edge e[100010];int main(){ int t,n,m,k; scanf("%d",&t); while(t--) { long long ans=0; memset(d1,0,sizeof(d1)); memset(d2,0,sizeof(d2)); scanf("%d %d %d",&n,&m,&k); for(int i=0;i<k;i++) { scanf("%d %d",&e[i].x,&e[i].y); d1[e[i].x]++; d2[e[i].y]++; } for(int i=0;i<k;i++) { ans+=(d1[e[i].x]-1)*(d2[e[i].y]-1); } cout<<ans*2<<endl; } return 0;}
新闻热点
疑难解答