10698 - Football Sort

All about problems in Volume 106. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

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

10698 - Football Sort

Post by Zyaad Jaunnoo » Mon May 02, 2005 12:04 pm

Hi Guyz...

I keep getting WA about this problem (although it sounds to be one of those straight forward problem). Is there some tricky test cases about this problem? If yes please post some along with their output. Thanks! :wink:

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan

Post by Eduard » Mon May 02, 2005 1:58 pm

Hello.
I think the best special test is the sample input.
Please read the old post about this problem.
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

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

Post by Zyaad Jaunnoo » Mon May 02, 2005 2:11 pm

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:

Post by Larry » Thu May 26, 2005 6:46 pm


mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Sat Dec 17, 2005 8:46 pm

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:

Post by mf » Sun Dec 18, 2005 1:26 am

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
Location: (CSE, SUST) Sylhet, Bangladesh
Contact:

Check With this I/O

Post by Mushfiqur Rahman » Sun Feb 25, 2007 3:24 am

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

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

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

Post by plamplam » Wed Jul 20, 2011 10:18 pm

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....
(I added the percentage later)
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

Post by seeva92 » Thu Nov 12, 2015 7:27 am

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");

	}
}

Post Reply

Return to “Volume 106 (10600-10699)”