|
|
back to boardWhy WA#2??? Help me!! Please Edited by author 01.04.2009 01:22 Re: Why WA#2??? Help me please!!! Edited by author 23.09.2009 02:03 Re: Why WA#2??? Hi, Make sure you split the input string about # and then convert the university name into lowercase (or uppercase) fully because two names with the same spelling are considered to be the same. Lebron and LeBron are the same ! I just kept adding the university names into a HashSet unless its size became q + 1. Re: Why WA#2??? and what it was ???? I convert the register of words #include <iostream> #include <stdio.h> using namespace std; struct team{ char name[35]; char name2[35]; int number; int place; }; team x[201]; int n; int fcmp(const void *p1,const void *p2){ for (int i=0;i<35;i++){ if ((*(team*)p1).name2[i]>(*(team*)p2).name2[i])return 1; if ((*(team*)p2).name2[i]>(*(team*)p1).name2[i])return -1; } return 0; } int fcmp1(const void *p1,const void *p2){ return (*(team*)p1).place-(*(team*)p2).place; } void kill(){ int j=-1; for (int i=0;i<(n);i++){ if (fcmp(&x[i],&x[i+1])){ x[++j]=x[i]; } } n=j+1; } void upper(char &a){ if ((a>=65)&&(a<=91)) a+=32; } int main(int argc, char* argv[]) { int y,q; cin>>y>>n>>q; char c; c=getchar(); for (int i=0;i<n;i++){ int h=0; char temp=1; x[i].number=1; x[i].place=i; temp=getchar(); while (temp!=10){ if (temp!='#'){ x[i].name[h++]=temp; upper(temp); x[i].name2[h-1]=temp; } else{ x[i].name[h++]='#'; x[i].name2[h-1]='#'; cin>>x[i].number; temp=10; c=getchar(); continue; } temp=getchar(); } x[i].name[h++]=0; x[i].name2[h-1]=0; } qsort(x,n,sizeof(team),fcmp); kill(); qsort(x,n,sizeof(team),fcmp1); cout<<x[q].name; if (x[q].name[strlen(x[q].name)-1]=='#') cout<<x[q].number; return 0; } |
|
|