hash做法:
#include<stdio.h>
#include<string.h>
const int Max = 100010;
int home[Max],away[Max],hash[Max];
int main()
{
int n,sum,total;
int i,j;
while(scanf("%d",&n)!=EOF)
{
sum = 0;
total = 2*(n-1);
for(i=0;i<n;i++)
scanf("%d %d",&home[i],&away[i]);
memset(hash,0,sizeof(hash));
for(i=0;i<n;i++)
hash[home[i]]++;//重复出现的主场number
for(i=0;i<n;i++)
printf("%d %d\n",n-1+hash[away[i]],n-1-hash[away[i]]);}
return 0;
}
CF 432B :Football Kit
时间: 2024-08-10 21:28:49