首页 > 代码库 > 432B - Football Kit

432B - Football Kit

解题思路:

暴力绝对TLE

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

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
const int MAXSIZE = 100;
const int INF = 0x3f3f3f3f;

int a[100001], b[100001], c[100001], cnt[100001];
int main(){
    int t, i, j, m, n;
    memset(c, 0, sizeof(c));
    memset(cnt, 0, sizeof(cnt));
    scanf("%d",&n);
    for(i = 1; i <= n; ++i){
        scanf("%d%d",&a[i],&b[i]);
        ++cnt[a[i]];
    }
    for(i = 1; i <= n; ++i){
        c[i] += n - 1;
        c[i] += cnt[b[i]];
    }
    int temp = (n - 1) * 2;
    for(i = 1; i <= n; ++i){
        printf("%d %d\n",c[i],temp - c[i]);
    }
    return 0;
}