import java.io.*;

public class ACMICPCContestScoring
{

	public static void main(String[] args) throws IOException
	{
		BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
		BufferedReader br = new BufferedReader(new FileReader (" "));

		
		String s = br.readLine();
		String[] array1 = s.split(" ");
		int numberOfTeams = Integer.parseInt(array1[0]);
		int numberOfProblems = Integer.parseInt(array1[1]);
		String[] timeStarted = array1[2].split(":");
		
		
		String[][] arrayTeamsStatusForProblems = new String[numberOfTeams][numberOfProblems];
		int[] arrayTeamsStatusForTimePenalty = new int[numberOfTeams];
		int[][] arrayTeamsStatusForTimePenaltyTemp = new int[numberOfTeams][numberOfProblems];
		
		for (int i = 0; i < numberOfTeams; i++)
		{
			for (int j = 0; j < numberOfProblems; j++)
			{
				arrayTeamsStatusForProblems[i][j] = "U";
			}
		}
		
		int[] numberOfProblemAttempts = new int[numberOfProblems];
		int[] numberOfAcceptedProblems = new int[numberOfProblems];
		int[] numberOfRejectedProblems = new int[numberOfProblems];
		int[][] arrayTeamsTimeOfLastAcceptedRun = new int[numberOfTeams][2];
		
		while (true)
		{
			String str = br.readLine();
						
			if (str != null)
			{
				String[] arrayStr = str.split(" ");
				arrayTeamsStatusForProblems[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] = arrayStr[3];
				
				if (arrayStr[3].equals("Y"))
				{
					numberOfAcceptedProblems[Integer.parseInt(arrayStr[2]) - 1]++;
					
					String[] timeSolved = arrayStr[0].split(":");
					
					arrayTeamsStatusForTimePenalty[Integer.parseInt(arrayStr[1]) - 1] += ((Integer.parseInt(timeSolved[0]) - Integer.parseInt(timeStarted[0])) * 60) + (Integer.parseInt(timeSolved[1]) - Integer.parseInt(timeStarted[1])); // ADD THE NUMBER OF ELAPSED MINUTES SINCE THE START OF THE CONTEST
					
					if (arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] > 0)
					{
						arrayTeamsStatusForTimePenalty[Integer.parseInt(arrayStr[1]) - 1] += arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1]; // ADD THE PREVIOUS COUNTED PENALTY POINTS FROM THE TEMP ARRAY
					}
					
					arrayTeamsTimeOfLastAcceptedRun[Integer.parseInt(arrayStr[1]) - 1][0] = Integer.parseInt(timeSolved[0]);
					arrayTeamsTimeOfLastAcceptedRun[Integer.parseInt(arrayStr[1]) - 1][1] = Integer.parseInt(timeSolved[1]);
				}
				else if (arrayStr[3].equals("N"))
				{
					numberOfRejectedProblems[Integer.parseInt(arrayStr[2]) - 1]++;
					arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] += 20;
				}
				
				numberOfProblemAttempts[Integer.parseInt(arrayStr[2]) - 1]++;
			}
			else
			{
				break;
			}
		}
		
		br.close();
		
		
		System.out.println();
		
		int[] numberOfSolvedProblems = new int[numberOfTeams];
		for (int i = 0; i < numberOfSolvedProblems.length; i++)
		{
			int ctrSolvedProblems = 0;
			
			for (int j = 0; j < numberOfProblems; j++)
			{				
				if (arrayTeamsStatusForProblems[i][j].equals("Y"))
				{
					ctrSolvedProblems++;
				}
			}
			
			numberOfSolvedProblems[i] = ctrSolvedProblems;
			
		
		int[] arrayRankOfTeams = new int[numberOfTeams];
		
		for (int o = 0; o < numberOfTeams; o++)
		{
			arrayRankOfTeams[i] = i + 1;
		}
		
		for (int k = 0; k < numberOfTeams - 1; k++)
		{
			for (int j = i + 1; j < numberOfTeams; j++)
			{
				if (numberOfSolvedProblems[i] < numberOfSolvedProblems[j]) // FIRST PHASE: ACCORDING TO THE NUMBER OF PROBLEMS SOLVED
				{
					int temp = numberOfSolvedProblems[i];
					numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
					numberOfSolvedProblems[j] = temp;
					
					int temp2 = arrayTeamsStatusForTimePenalty[i];
					arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
					arrayTeamsStatusForTimePenalty[j] = temp2;
					
					int temp3 = arrayRankOfTeams[i];
					arrayRankOfTeams[i] = arrayRankOfTeams[j];
					arrayRankOfTeams[j] = temp3;
				}
				else if (numberOfSolvedProblems[i] == numberOfSolvedProblems[j])
				{
					if (arrayTeamsStatusForTimePenalty[i] > arrayTeamsStatusForTimePenalty[j])
					{
						int temp = numberOfSolvedProblems[i];
						numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
						numberOfSolvedProblems[j] = temp;
						
						int temp2 = arrayTeamsStatusForTimePenalty[i];
						arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
						arrayTeamsStatusForTimePenalty[j] = temp2;
						
						int temp3 = arrayRankOfTeams[i];
						arrayRankOfTeams[i] = arrayRankOfTeams[j];
						arrayRankOfTeams[j] = temp3;
					}
					else if (arrayTeamsStatusForTimePenalty[i] > 0 && arrayTeamsStatusForTimePenalty[i] == arrayTeamsStatusForTimePenalty[j])
					{
						if (arrayTeamsTimeOfLastAcceptedRun[i][0] < arrayTeamsTimeOfLastAcceptedRun[j][0])
						{
							int temp = numberOfSolvedProblems[i];
							numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
							numberOfSolvedProblems[j] = temp;
							
							int temp2 = arrayTeamsStatusForTimePenalty[i];
							arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
							arrayTeamsStatusForTimePenalty[j] = temp2;
							
							int temp3 = arrayRankOfTeams[i];
							arrayRankOfTeams[i] = arrayRankOfTeams[j];
							arrayRankOfTeams[j] = temp3;
						}
						else if (arrayTeamsTimeOfLastAcceptedRun[i][0] == arrayTeamsTimeOfLastAcceptedRun[j][0] && arrayTeamsTimeOfLastAcceptedRun[i][1] < arrayTeamsTimeOfLastAcceptedRun[j][1])
						{
							int temp = numberOfSolvedProblems[i];
							numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
							numberOfSolvedProblems[j] = temp;
							
							int temp2 = arrayTeamsStatusForTimePenalty[i];
							arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
							arrayTeamsStatusForTimePenalty[j] = temp2;
							
							int temp3 = arrayRankOfTeams[i];
							arrayRankOfTeams[i] = arrayRankOfTeams[j];
							arrayRankOfTeams[j] = temp3;
						}						
					}
					else
					{
						if (i > j)
						{
							int temp3 = arrayRankOfTeams[i];
							arrayRankOfTeams[i] = arrayRankOfTeams[j];
							arrayRankOfTeams[j] = temp3;
						}
					}
				}
			}
		}
		
		// OUTPUT
		
		PrintWriter pw = new PrintWriter(new FileWriter("renjei.txt"));
		
		pw.println("CONTEST RESULTS");
		pw.printf("%10s", "RANK");
		pw.printf("%10s", "TEAM");
		pw.printf("%10s", "SOLVED");
		pw.printf("%10s%n", "PENALTY");
		
		for (int a = 0, rank = 1; a < numberOfTeams; a++, rank++)
		{
			pw.printf("%10s", rank);
			pw.printf("%10s", arrayRankOfTeams[i]);
			pw.printf("%10s", numberOfSolvedProblems[i]);
			pw.printf("%10s%n", arrayTeamsStatusForTimePenalty[i]);
			
			if (i + 1 < numberOfTeams && numberOfSolvedProblems[i] == numberOfSolvedProblems[i + 1] && arrayTeamsStatusForTimePenalty[i] == arrayTeamsStatusForTimePenalty[i + 1])
			{
				rank--;
			}
			else
			{
				rank = i + 1;
			}
		}
		
		pw.println();
		pw.println("PROBLEM SOLUTION STATISTICS");
		pw.printf("%10s", "PROBLEM");
		pw.printf("%10s", "ATTEMPTS");
		pw.printf("%10s", "ACCEPTED");
		pw.printf("%10s%n", "REJECTED");
		
		for (int n = 0; n < numberOfProblems; n++)
		{
			pw.printf("%10d", (i + 1));
			pw.printf("%10d", numberOfProblemAttempts[i]);
			pw.printf("%10d", numberOfAcceptedProblems[i]);
			pw.printf("%10d%n", numberOfRejectedProblems[i]);
		}
		
		pw.close();
		
		
		
		
		System.out.println();
		
		for (int m = 0; m < numberOfTeams; m++)
		{
			System.out.print("Team #" + (i + 1) + ": ");
			for (int j = 0; j < numberOfProblems; j++)
			{
				System.out.print(arrayTeamsStatusForProblems[i][j] + ",");
			}
			System.out.println();
		}
		
		
		System.out.println();
		
		for (int h = 0; h < numberOfTeams; h++)
		{
			System.out.println("Team #" + (i + 1) + " solved " + numberOfSolvedProblems[i] + " problems.");
		}
		
		
		System.out.println();
		
		for (int g = 0; g < numberOfTeams; g++)
		{
			System.out.print("Total Time Penalty of Team #" + (i + 1) + ": " + arrayTeamsStatusForTimePenalty[i]);
			System.out.println();
		}
			
		System.out.println();
		
		for (int f = 0; f < numberOfTeams; f++)
		{
			System.out.print("Rank #" + (i + 1) + ": " + arrayRankOfTeams[i]);
			System.out.println();
		}
		
	}
  }
}

And? What is this for? What is it suppossed to be, other than a procedural program masquerading as a Java program?

Did you have a question? Or did you simply want to show the world that you
1) Have no idea what OOP is
2) Have no idea how to post code to a forum

I want to complete this program. I don't know the functions of each codes that's why I can't execute the program correctly. Can you help me please.

Maybe. If you post the code correctly (use code tags) and actually ask a specific question, and give detailed explanations of what, up to this point, is not working as it should, and what the difference is.

the program is said to be process completed but the problem is I cant trace the concept of the program.

And I have no idea what you mean with that statement.

Is this your code? If so, what problem are you having with it? If not, ask the entity from which you received the code.

This article has been dead for over six months. Start a new discussion instead.