UVA10194 - Football (aka Soccer)
2012-07-25 10:44
495 查看
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1135
好繁琐的一道模拟题 细节很重要 编译错误一次 把字符串结尾写错WA一次 多了getchar()WA一次 多了以空格PE一次 最后AC...3个多小时
用了一下map map还是很方便的
View Code
好繁琐的一道模拟题 细节很重要 编译错误一次 把字符串结尾写错WA一次 多了getchar()WA一次 多了以空格PE一次 最后AC...3个多小时
用了一下map map还是很方便的
View Code
#include <iostream> #include<map> #include<stdio.h> #include<string> #include<string.h> #include<stdlib.h> using namespace std; typedef struct node { int a,b,c,d,e,f,g,h,i; char j[31]; node() { a = 0; b = 0; c = 0; d = 0; e = 0; f = 0; g = 0; h = 0; i = 0; } }st; map <string, int> ff; int cmp(const void *x,const void *y) { if(((st *)x)->b!=((st *)y)->b) return ((st *)y)->b-((st *)x)->b; else if(((st *)x)->d!=((st *)y)->d) return (((st *)y)->d-((st *)x)->d); else if(((st *)x)->g!=((st *)y)->g) return (((st *)y)->g-((st *)x)->g); else if(((st *)x)->h!=((st *)y)->h) return (((st *)y)->h-((st *)x)->h); else if(((st *)x)->c!=((st *)y)->c) return (((st *)x)->c-((st *)y)->c); else return strcasecmp(((st *)x)->j,((st *)y)->j); } int main() { int n,t,k,i,j; char str[101],team[31][31],com[101],sw[101],cw[101],tw[101]; cin>>n; getchar(); while(n--) { st q[101]; gets(str); cin>>t; getchar(); ff.clear(); for(i = 0; i < t ; i++) { gets(team[i]); ff[team[i]] = i; strcpy(q[ff[team[i]]].j,team[i]); } cin>>k; getchar(); while(k--) { gets(com); int temp; for(i = 0 ; i < strlen(com) ; i++) { if(com[i]!='#') sw[i]=com[i]; else { temp = i; break; } } sw[temp] = '\0'; q[ff[sw]].c++; int o1 = 0,o2 = 0; for(i = temp+1 ; i < strlen(com) ; i++) { if(com[i]!='@') tw[o1++] = com[i]; else { temp = i; break; } } tw[o1] = '\0'; o1 = atoi(tw); for(i = temp+1 ; i < strlen(com) ; i++) { if(com[i]!='#') tw[o2++] = com[i]; else { temp = i; break; } } tw[o2] = '\0'; o2 = atoi(tw); int o3 = 0; for(i = temp+1; i < strlen(com) ; i++) cw[o3++] = com[i]; cw[o3]='\0'; q[ff[cw]].c++; q[ff[sw]].h += o1; q[ff[sw]].i += o2; q[ff[cw]].h += o2; q[ff[cw]].i += o1; if(o2>o1) { q[ff[cw]].d++; q[ff[sw]].f++; q[ff[cw]].b+=3; } else if(o2<o1) { q[ff[sw]].d++; q[ff[cw]].f++; q[ff[sw]].b+=3; } else { q[ff[sw]].e++; q[ff[cw]].e++; q[ff[sw]].b++; q[ff[cw]].b++; } } cout<<str<<endl; for(i = 0 ; i < t ; i++) q[i].g = q[i].h-q[i].i; qsort((void *)q,t,sizeof(q[0]),cmp); for(i = 0 ; i < t ; i++) { cout<<i+1<<") "<<q[i].j<<" "<<q[i].b<<"p, "<<q[i].c<<"g ("<<q[i].d<<"-"<<q[i].e<<"-"<<q[i].f<<"), "<<q[i].h-q[i].i<<"gd ("<<q[i].h<<"-"<<q[i].i<<")"<<endl; } if(n!=0) puts(""); } return 0; }
相关文章推荐
- UVA 10194 - Football (aka Soccer)
- UVa 10194 Football (aka Soccer) (模拟)
- UVa 10194 - Football (aka Soccer)
- UVA10194 Football (aka Soccer) 排序
- UVA - 10194 Football (aka Soccer) 多种排序
- UVA10194 - Football (aka Soccer)
- uva 10194 Football (aka Soccer)
- uva 10194 Football (aka Soccer)
- UVa 10194 - Football (aka Soccer)
- uva 10194 - Football (aka Soccer)
- UVA 10194 Football (aka Soccer) 足球成绩统计 检索+模拟
- UVA - 10194 Football (aka Soccer)(sort函数用法)
- UVA 10194 Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- uva 10194 - Football (aka Soccer)
- uva 10194 Football (aka Soccer)
- UVA 10194 - Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- UVA 10194 Football (aka Soccer)
- UVa Problem Solution: 10194 - Football (aka Soccer)