Start: Jun, 26, 2019 08:30:00
2019年度暑期短学期第一天
End: Jun, 26, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: I
Result: Accepted
Time: 6ms
Memory: 2952kB
Author: 2017212212209
In contest: 1273

#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
using namespace std;
struct team
{
	char teamname[505];
	char stuname[505];
	int sex;
	double score;
	team()
	{
		score = 0;
	}
}a[600], b[600];
int mao[600], old[600];
int n, m, r, s, q, p, c;
bool Prime(int x) {
	for (int i = 2; i <= (int)sqrt((double)x); i++)
		if (x%i == 0)
			return false;
	return true;
}
double get(int x)
{
	for (int i = 0; i<r; i++) {
		if (x == mao[i])
			return 2.5;
	}
	for (int i = 0; i<s; i++) {
		if (x == old[i])
			return 1.5;
	}
	if (Prime(x))
		return 1;
	else
		return 0.3;
}
double Max(double a, double b)
{
	if (a > b)
		return a;
	else
		return b;
}
int cmp1(int a, int b)
{
	return a > b;;
}
int cmp2(team a, team b)
{
	return a.score>b.score;
}
int main()
{
	int t;
	scanf("%d", &t);
	while (t--)
	{
		for (int i = 0; i < 600; i++)
		{
			a[i].score = 0;
			b[i].score = 0;
		}
		memset(mao, 0, sizeof(mao));
		memset(old, 0, sizeof(old));
		scanf("%d %d", &n, &m);
		scanf("%d", &r);
		for (int i = 0; i < r; i++) scanf("%d", &mao[i]);
		scanf("%d", &s);
		for (int i = 0; i < s; i++) scanf("%d", &old[i]);
		scanf("%d", &q);
		for (int i = 0; i < q; i++)
		{
			int rank;
			scanf("%s %d", b[i].teamname, &rank);
			if (rank == 1)
				b[i].score += 36;
			else if (rank == 2)
				b[i].score += 27;
			else if (rank == 3)
				b[i].score += 18;
		}
		for (int i = 0; i < n; i++)
		{
			char name[505], xb;
			int num, timenum;
			scanf("%s %s %c %d %d", a[i].stuname, name, &xb, &num, &timenum);
			if (xb == 'F')
				a[i].score += 33;
			for (int j = 0; j < q; j++)
			{
				if (strcmp(name, b[j].teamname) == 0)
				{
					strcpy(a[i].teamname, b[j].teamname);
					a[i].score += b[j].score;
				}
			}
			for (int j = 0; j < num; j++)
			{
				int id;
				scanf("%d", &id);
				a[i].score += get(id);
			}
			int time[2000];
			for (int j = 0; j < timenum; j++)
			{
				scanf("%d", &time[j]);
			}
			if (timenum >= 3)
			{
				sort(time, time + timenum, cmp1);
				a[i].score += Max(0, ((time[2] - 1200.0) / 100)*1.5);
			}
		}
		sort(a, a + n, cmp2);
		for (int i = 0; i < m; i++)
		{
			printf("%s %.3lf\n", a[i].stuname, a[i].score);
		}
	}
	return 0;
}