432B - Football Kit

时间:2023-12-09 22:17:43

解题思路:

暴力绝对TLE

一个队伍穿主场球衣的次数 = 这个队伍的客场球衣颜色与其他队主场球衣颜色起冲突的次数 + (n - 1)

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
const int MAXSIZE = ;
const int INF = 0x3f3f3f3f; int a[], b[], c[], cnt[];
int main(){
int t, i, j, m, n;
memset(c, , sizeof(c));
memset(cnt, , sizeof(cnt));
scanf("%d",&n);
for(i = ; i <= n; ++i){
scanf("%d%d",&a[i],&b[i]);
++cnt[a[i]];
}
for(i = ; i <= n; ++i){
c[i] += n - ;
c[i] += cnt[b[i]];
}
int temp = (n - ) * ;
for(i = ; i <= n; ++i){
printf("%d %d\n",c[i],temp - c[i]);
}
return ;
}