ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1680. The First Nonqualifying

Why WA#2???
Posted by Baranova_ED(YSPU) 1 Apr 2009 01:19
Help me!! Please


Edited by author 01.04.2009 01:22
Re: Why WA#2???
Posted by Baranova_ED(YSPU) 12 Apr 2009 00:53

Help me please!!!

Edited by author 23.09.2009 02:03
Re: Why WA#2???
Posted by Varun Sharma 10 May 2009 12:58
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???
Posted by Baranova_ED(YSPU) 23 Sep 2009 02:04
Thanks
Re: Why WA#2???
Posted by Childofbodom(It-Team) 19 Oct 2009 04:29
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;
}