2014
03-13

# Acm Team Section

The ACM-ICPC brings together the top student programmers from all over the world, and provides them with opportunities to develop critical skills which will give them a competitive edge when they launch careers in information technology areas. More than 5,600 teams from 84 countries had competed in regional contests last year. An ever larger number of teams – more than 7,000 teams from different countries worldwide – have registered in this year’s regional contests. However, due to the limited capacity of each site, only a small amount of the registered teams can be allowed to participate in the on-site contest. It is really hard for the contest organizers to determine which teams should be allowed to participate. One of the possible solutions is to hold a preliminary internet contest before the on-site competition. The following part describes a simplified version of rules for team selection:

Up to three teams from each school can participate in the on-site contest, depending on how many following conditions the school in question meets:

a)
A team from this school has solved at least M problems in the preliminary contest;
b)
Some of the teams from this school ranked top 20 in previous World Finals;
c)
This school has hosted a provincial contest this year.

Your task is to write a program to help the contest holders to calculate how many teams are allowed to participate in the on-site final contest.

There are multiple test cases in the input file. Each test case starts with three integers S , T and M (1<=S<=100, 1<=T<=2000, 0<=M<=10) , representing the number of schools, the number of teams participating in the preliminary contest, and the minimum number of problems which is required to be solved in order to enter the on-site competition, respectively.

Each of the following S lines consists of three integers Id , P and Q , (1<=Id<=S, 0<=P, Q<=1) , representing the Id of the school, whether this school satisfies condition b), and whether this school satisfies condition c).

The last part of each test case consists of T lines. There are two integers on each of the T lines, Sid and Tot (1<=Sid<=S, 0<=Tot<=10) , meaning that a team from school Sid had solved Tot problems in the preliminary contest.

Two consecutive test cases are separated by a blank line. S = 0, T = 0, M = 0 indicates the end of input and should not be processed by your program.

There are multiple test cases in the input file. Each test case starts with three integers S , T and M (1<=S<=100, 1<=T<=2000, 0<=M<=10) , representing the number of schools, the number of teams participating in the preliminary contest, and the minimum number of problems which is required to be solved in order to enter the on-site competition, respectively.

Each of the following S lines consists of three integers Id , P and Q , (1<=Id<=S, 0<=P, Q<=1) , representing the Id of the school, whether this school satisfies condition b), and whether this school satisfies condition c).

The last part of each test case consists of T lines. There are two integers on each of the T lines, Sid and Tot (1<=Sid<=S, 0<=Tot<=10) , meaning that a team from school Sid had solved Tot problems in the preliminary contest.

Two consecutive test cases are separated by a blank line. S = 0, T = 0, M = 0 indicates the end of input and should not be processed by your program.

5 8 6
5 0 1
4 0 0
1 0 0
3 1 1
2 1 1
2 6
3 3
2 9
5 7
4 8
3 6
2 8
1 6

5 8 6
3 0 1
5 1 1
2 0 1
1 1 1
4 1 0
5 7
2 5
4 5
5 5
3 3
5 6
2 0
4 7

0 0 0

Case 1: 10
Case 2: 9

#include <stdio.h>
#include <string.h>

int s,t,m;
bool vi[110];
int id[110];

int main()
{
//	freopen("1.txt", "r", stdin);
int a,b;
int ans;
int i,j;
int T=0;
while (scanf("%d %d %d",&s,&t,&m)!=EOF && (s>0 || t>0 || m>0))
{
T++;
memset(vi,false,sizeof(vi));
ans=0;
for (i=0;i<s;i++)
{
scanf("%d %d %d",&id[i],&a,&b);
ans+=a+b;
}
for (i=0;i<t;i++)
{
scanf("%d %d",&a,&b);
if (b>=m)
{
for (j=0;j<s;j++)
{
if (id[j]==a)
{
if (!vi[j])
{
vi[j]=true;
ans++;
}
break;
}
}
}
}
printf("Case %d: %d\n",T,ans);
}

return 0;
}

1. 问题3是不是应该为1/4 .因为截取的三段，无论是否能组成三角形， x， y-x ，1-y,都应大于0，所以 x<y,基础应该是一个大三角形。小三角是大三角的 1/4.