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;
}

432B - Football Kit,布布扣,bubuko.com

时间: 2024-11-04 05:59:41

432B - Football Kit的相关文章

CF 432B :Football Kit

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("

CodeForces 432B Football Kit

Football Kit Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 432B Description Consider a football tournament where n teams participate. Each team has two football kits: for home games, a

CodeForces 432B Football Kit(水)

Description Consider a football tournament where n teams participate. Each team has two football kits: for home games, and for away games. The kit for home games of the i-th team has color xi and the kit for away games of this team has color yi(xi ≠ 

Codeforces Round #246 (Div. 2) B. Football Kit

题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服   如果客场与主场的衣服相同,则穿主场衣服 则只需要标记主场每种衣服有多少球队,当作为客场时查找与客场颜色相同的主场球队有多少即可 #include <iostream> #include <map> #include <vector> #include <algor

Codeforces Round #246 (Div. 2)

A.Choosing Teams 水题 #include <cstdio> #include <cstring> using namespace std; int main() { int n, k, ans, i, x; scanf("%d%d",&n,&k); ans = 0; for(i=0; i<n; ++i) { scanf("%d",&x); if(5-x >= k) ans++; } ans

Codeforces Round #246 (Div. 2) (ABCD详细题解)

比赛链接:http://codeforces.com/contest/432 A. Choosing Teams time limit per test:1 second memory limit per test:256 megabytes The Saratov State University Olympiad Programmers Training Center (SSU OPTC) has n students. For each student you know the numbe

Codeforces Round #281 (Div. 2) A. Vasya and Football 暴力

A. Vasya and Football Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second yellow card automatically receives a red

[UI] MFD UI kit

MFD UI kit https://dribbble.com/whaledesigned

POJ 3071 Football

Description Consider a single-elimination football tournament involving 2n teams, denoted 1, 2, -, 2n. In each round of the tournament, all teams still in the tournament are placed in a list in order of increasing index. Then, the first team in the l