codeforces 200C Football Championship

字符串题,基于cpp模板的声明,先声明了n个函数原型,其中T代替任何数据类型,然后给了m种变量的声明,又给了k 个函数的声明,用的是之前那m个变量,问每个函数分别能匹配多少个函数原型


先是字符串处理,然后暴力循环,用变量类型替换变量名,直接判断是否匹配然后统计答案即可

#include <iostream>
#include <map>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#define rep(i, j, k) for(ll i = j; i <= k; i++)
#define ll long long
#define maxn 500009
#define inf 0x7fffffff

using namespace std;

int n, point[10], dif[10], score[109];
int game[10], opp;
string s[10];
map <string, int> mp;

bool bigger (int x, int y)
{
	if (point[x] > point[y])
		return 1;
	if (point[x] == point[y])
	{
		if (dif[x] > dif[y])
			return 1;
		if (dif[x] == dif[y])
		{
			if (score[x] > score[y])
				return 1;
			if (score[x] == score[y])
				return s[x] < s[y];
		}
	}
	return 0;
}

int main ()
{
	mp["BERLAND"] = 2;
	s[2] = "BERLAND";
	int cnt = 0;
	rep (i, 1, 5)
	{
		string s1, s2;
		cin >> s1 >> s2;
		if (!mp[s1])
			cnt += 1 + (cnt == 1), mp[s1] = cnt, s[cnt] = s1;
		if (!mp[s2])
			cnt += 1 + (cnt == 1), mp[s2] = cnt, s[cnt] = s2;
		int u, v;
		scanf ("%d:%d", &u, &v);
		if (u > v)
			point[mp[s1]] += 3;
		else
			if (u < v)
				point[mp[s2]] += 3;
			else
				point[mp[s1]] ++, point[mp[s2]]++;
		dif[mp[s1]] += u - v, dif[mp[s2]] += v - u;
		score[mp[s1]] += u, score[mp[s2]] += v;
		game[mp[s1]]++, game[mp[s2]]++;
	}
	rep (i, 1, 4)
		if (game[i] < 3 && i != 2)
			opp = i;
	point[2] += 3;
	int big_ = 0;
	rep (i, 1, 4)
		if (point[i] > point[2])
			big_++;
	if (big_ >= 2)
	{
		printf ("IMPOSSIBLE\n");
		return 0;
	}
	//rep (i,1, 4) printf ("num %d point   %d  dif %d score %d\n", i, point[i], dif[i], score[i]); cout << endl;
	int ans = 0;
	while (1)
	{
		dif[2]++, score[2]++;
		dif[opp]--;
		ans++;
		rep (i, 0, 1000)
		{
			score[2] += i, score[opp] += i;
			int now = 0;
			rep (i, 1, 4)
				if (bigger (i, 2))
					now++;
			if (now <= 1)
			{
				//rep (i,1, 4) printf ("num %d point   %d  dif %d score %d    ", i, point[i], dif[i], score[i]), cout << s[i] << endl;
				cout << ans + i << ':' << i << endl;
				return 0;
			}
			score[2] -= i, score[opp] -= i;
		}
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值