## 10698 - Football Sort

Moderator: Board moderators

Experienced poster
Posts: 122
Joined: Tue Apr 16, 2002 10:07 am

### 10698 - Football Sort

Hi Guyz...

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan
Hello.
I think the best special test is the sample input.
http://online-judge.uva.es/board/viewto ... tball+sort
Eduard
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650

Experienced poster
Posts: 122
Joined: Tue Apr 16, 2002 10:07 am
Thanks Eduard
My program passes the sample input though...

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
Could someone clarify what is meant by "percentage of earned points" in this problem (#10698)?
It's ratio of team's earned points to what?

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
Nevermind, I've figured it out. It's ratio to 3 times the number of team's played games. What a poorly-written problem!

Mushfiqur Rahman
Learning poster
Posts: 56
Joined: Tue Jun 13, 2006 5:18 pm
Contact:

### Check With this I/O

I got 4 times WA in this problem. Lastly I found my bug. I generate this Input and got the bug. May be it would be helpful for u.

Input:

Code: Select all

``````2 0
B
a
``````
Output:

Code: Select all

`````` 1.               a   0   0   0   0   0    N/A
B   0   0   0   0   0    N/A
``````

plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

### Re: contest 2004-8-7 problem C - Football Sort

The problem-setter is a couch potato, very dull and anooying problem description. I had a hard time counting all the spaces and shit...got PE twice before Accepted.

Code: Select all

``````My output format is:
if I am printing team position: printf("%2d.%16s%4d%4d%4d%4d%4d "); etc etc...
else printf("%19s%4d%4d%4d%4d%4d "); etc....
``````
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

seeva92
New poster
Posts: 3
Joined: Fri Oct 09, 2015 7:57 am

### Re: 10698 - Football Sort

Hi all,

I am stuck with this problem. Anyone help me out on where my code fails

Code: Select all

``````#include <iostream>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <algorithm>
#include <sstream>
#include <set>
#include <climits>
#include <cstdio>
#include <string>
#include <map>
#include <unordered_map>
#ifndef ONLINE_JUDGE
#define getc_unlocked getc
#define putc_unlocked putc
#endif
using namespace std;
struct Team {
string name;
int scored = 0;
int suffered = 0;
int points = 0;
int played = 0;
int difference = 0;
int idx = 0;
};
int getpoints(int goal1, int goal2) {
if (goal1 == goal2)
return 1;
else if (goal1 > goal2)
return 3;
return 0;
}
bool compare(Team team1, Team team2) {
if (team1.points > team2.points)
return true;
else if (team1.points == team2.points) {
if (team1.difference > team2.difference)
return true;
else if (team1.difference == team2.difference) {
if (team1.scored > team2.scored)
return true;
else if (team1.scored == team2.scored) {
transform(team1.name.begin(), team1.name.end(), team1.name.begin(), ::tolower);
transform(team2.name.begin(), team2.name.end(), team2.name.begin(), ::tolower);
if (team1.name <= team2.name)
return true;
return false;
}
return false;
}
return false;
}
return false;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("1.txt", "r", stdin);
freopen("2.txt", "w", stdout);
#endif
register int g, t;

string str;
register int goal1, goal2;
char c;
cin >> g >> t;
while (g || t) {
map<string, int> teamMap;
vector<Team> teamList;
int idx = 0;
while (g--) {
cin >> str;
Team team; team.name = str; team.idx = idx;
teamList.push_back(team);
teamMap[str] = idx++;
}
while (t--) {
cin >> str >> goal1 >> c >> goal2;
Team & team = teamList[teamMap[str]];
team.scored += goal1;
team.suffered += goal2;
team.points += getpoints(goal1, goal2);
team.played++; team.difference = team.scored - team.suffered;

cin >> str;
Team &team1 = teamList[teamMap[str]];
team1.scored += goal2;
team1.suffered += goal1;
team1.points += getpoints(goal2, goal1);
team1.played++; team1.difference = team1.scored - team1.suffered;
}

stable_sort(teamList.begin(), teamList.end(), compare);
double result = 0.0f;
char na[] = "N/A";
for (int i = 1; i <= (int)teamList.size(); i++) {
result = ((double(teamList[i - 1].points)) / (double(teamList[i - 1].played * 3))) * (double(100));
if (i - 2 >= 0) {
if ((teamList[i - 1].points == teamList[i - 2].points) && (teamList[i - 1].difference == teamList[i - 2].difference) && (teamList[i - 1].scored == teamList[i - 2].scored))
printf("%19s%4d%4d%4d%4d%4d ", teamList[i - 1].name.c_str(), teamList[i - 1].points, teamList[i - 1].played, teamList[i - 1].scored, teamList[i - 1].suffered, teamList[i - 1].difference);
else
printf("%2d.%16s%4d%4d%4d%4d%4d ", i, teamList[i - 1].name.c_str(), teamList[i - 1].points, teamList[i - 1].played, teamList[i - 1].scored, teamList[i - 1].suffered, teamList[i - 1].difference);
} else
printf("%2d.%16s%4d%4d%4d%4d%4d ", i, teamList[i - 1].name.c_str(), teamList[i - 1].points, teamList[i - 1].played, teamList[i - 1].scored, teamList[i - 1].suffered, teamList[i - 1].difference);

if (result != result)
printf("%6s\n", na);
else
printf("%6.2f\n", result);
}
cin >> g >> t;
if (g != 0 && t != 0)
printf("\n");

}
}
``````