hdu 1225大水题
2013-06-01 00:36
357 查看
/* * hdu1225/win.cpp * Created on: 2013-5-31 * Author : ben */ #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <ctime> #include <iostream> #include <algorithm> #include <queue> #include <set> #include <map> #include <stack> #include <string> #include <vector> #include <deque> #include <list> #include <functional> #include <numeric> #include <cctype> using namespace std; #ifndef ONLINE_JUDGE const int MAXN = 60; #else const int MAXN = 6000; #endif typedef struct Person { char name[40]; int win; int lost; int score; }Person; Person persons[MAXN]; map<string, int> mymap; int pn; inline int getNameId(const char *str) { string temp(str); if(mymap.count(temp) > 0) { return mymap[temp]; } strcpy(persons[pn].name, str); mymap[temp] = pn; return pn++; } inline bool operator<(const Person& p1, const Person& p2) { if(p1.score != p2.score) { return p1.score > p2.score; } if(p1.win - p1.lost != p2.win - p2.lost) { return p1.win - p1.lost > p2.win - p2.lost; } if(p1.win != p2.win) { return p1.win > p2.win; } return string(p1.name) < string(p2.name); } int main() { #ifndef ONLINE_JUDGE freopen("data.in", "r", stdin); #endif char name1[40], name2[40]; int N, n, a, b; while(scanf("%d", &n) == 1) { memset(persons, 0, sizeof(persons)); mymap.clear(); N = n * (n - 1); pn = 0; while(N--) { scanf(" %s VS %s %d:%d", name1, name2, &a, &b); int i = getNameId(name1); int j = getNameId(name2); persons[i].win += a; persons[i].lost += b; persons[j].win += b; persons[j].lost += a; if(a > b) { persons[i].score += 3; }else if(a < b) { persons[j].score += 3; }else { persons[i].score++; persons[j].score++; } } sort(persons, persons + n); for(int i = 0; i < n; i++) { printf("%s %d\n", persons[i].name, persons[i].score); } putchar('\n'); } return 0; }
相关文章推荐
- HDU1225 Football Score 【结构体排序】
- HDU 5551 Huatuo's Medicine(宇宙无敌炒鸡大水题)
- hdu1029_大水题(思维)
- hdu 1048 The Hardest Problem Ever 大水题
- HDU-1225-Football Score
- hdu 2550 百步穿杨(大水题)
- HDU 2008 数值统计(大水题)
- hdu 2547无剑无我 大水题透露自己的缺点
- hdu 4548 美素数 超级大水题
- HDU 5365 Run(大水题)
- HDU 1542 HDU 1225 (线段树扫描线)
- HDU-1225-Football Score
- HDU 1225 Football Score
- hdu 2550 百步穿杨(大水题)
- hdu 1225 求覆盖至少两次的区域的面积并
- HDU2060 大水题 斯诺克
- hdu 1013 Digital Roots 用一个大水题来纪念我进入杭电前一万名
- hdu 4247 大水题
- HDU 2564 词组缩写 标准大水题
- HDU-5504(逻辑if-else大水题)