codeforces 200C Football Championship

来源:互联网 发布:gcc windows 64 下载 编辑:程序博客网 时间:2024/05/04 13:51

字符串题,基于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 0x7fffffffusing 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;elseif (u < v)point[mp[s2]] += 3;elsepoint[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
原创粉丝点击