HDU-1225 Football Score 模拟问题(水题)
2018-02-06 21:15
429 查看
题目链接:https://cn.vjudge.net/problem/HDU-1225
水题
代码
#include <algorithm> #include <string> #include <cstdio> #include <map> using namespace std; struct Team{ int score[3]; string name; Team(string name="", int s1=0, int s2=0, int s3=0):name(name) { score[0]=s1; score[1]=s2; score[2]=s3; } bool operator < (const Team &a) const{ if (score[0]!=a.score[0]) return score[0]>a.score[0]; if (score[1]!=a.score[1]) return score[1]>a.score[1]; if (score[2]!=a.score[2]) return score[2]>a.score[2]; return name<a.name; } }arr[1000+5]; int main(void){ int n; while (scanf("%d", &n)==1 && n){ map<string, int> getidx; int size=0, end=n*(n-1), scores[2][3], s[2]; char teamname[2][1000]; for (int i=0; i<end; i++){ scanf("%s%*s%s%d:%d", teamname[0], teamname[1], &s[0], &s[1]); if (s[0]==s[1]) scores[0][0]=scores[1][0]=1; else if (s[0]>s[1]) scores[0][0]=3, scores[1][0]=0; else scores[0][0]=0, scores[1][0]=3; scores[0][1]=s[0]-s[1]; scores[0][2]=s[0]; scores[1][1]=s[1]-s[0]; scores[1][2]=s[1]; for (int i=0; i<2; i++){ if (!getidx.count(teamname[i])){ getidx[teamname[i]]=size++; arr[getidx[teamname[i]]]=Team(teamname[i], scores[i][0], scores[i][1], scores[i][2]); }else for (int j=0; j<3; j++) arr[getidx[teamname[i]]].score[j]+=scores[i][j]; } } sort(arr, arr+size); for (int i=0; i<size; i++) printf("%s %d\n", arr[i].name.c_str(), arr[i].score[0]); printf("\n"); } return 0; }
相关文章推荐
- HDU-1034 Candy Sharing Game 模拟问题(水题)
- HDU-1035 Robot Motion 模拟问题(水题)
- HDU-1032 The 3n+1 problem 模拟问题(水题)
- hdu 4841 圆桌问题(用vector模拟约瑟夫环)
- HDU 5095 Linearization of the kernel functions in SVM(模拟, 水题)
- HDU 1276 士兵队列训练问题 【模拟】
- HDU 1099 Lottery (数学问题模拟)
- hdu 4772 Zhuge Liang's Password【模拟】水题
- HDU 1482 模拟天平问题
- hdu 5402 Travelling Salesman Problem(模拟,棋盘染色问题)
- hdu 1491(Octorber 21st)(模拟水题)
- HDU 5319 两把刷子刷墙问题(多校)-直接模拟
- HDU 1031 Design T-Shirt 模拟 水题
- hdu 1878 欧拉回路 水题。测试数据貌似有点问题
- HDU 1234 开门人和关门人(模拟水题)
- HDU 3635 Dragon Balls 并查集水题 模拟
- 小孩报数问题(模拟水题)
- HDU-5835 Danganronpa(模拟水题)
- hdu_5670 进制问题+数学水题
- hdu 2598 Manipulating the Power Square 模拟水题