Go: // You Are the Judge(審判は君だ！)
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2400&lang=jp
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Team struct {
	TID         int
	Accepted    int
	WrongAnswer map[int]int
	Penalty     int
}

type Teams []Team

func (t Teams) Len() int      { return len(t) }
func (t Teams) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
func (t Teams) Less(i, j int) bool {
	// より多くの問題を解いたチームは順位が上になる
	if t[i].Accepted > t[j].Accepted {
		return true
	} else if t[i].Accepted == t[j].Accepted {
		// 解いた問題が同じ場合、ペナルティの少ないチームのほうが順位が上になる
		if t[i].Penalty < t[j].Penalty {
			return true
		} else if t[i].Penalty == t[j].Penalty {
			// 解いた問題もペナルティも同じ場合、チーム番号が小さいほうのチームが順位が上になる
			if t[i].TID < t[j].TID {
				return true
			}
		}
	}
	return false
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	for {
		t, p, r := nextInt(sc), nextInt(sc), nextInt(sc)
		if t == 0 && p == 0 && r == 0 {
			break
		}

		teams := []Team{}
		for tID := 0; tID < t; tID++ {
			teams = append(teams, Team{tID + 1, 0, map[int]int{}, 0})
		}

		for i := 0; i < r; i++ {
			tID, pID, time, message := nextInt(sc), nextInt(sc), nextInt(sc), nextString(sc)
			tID--

			if message == "CORRECT" {
				teams[tID].Accepted++
				wa, _ := teams[tID].WrongAnswer[pID]
				teams[tID].Penalty += wa*1200 + time
			} else {
				teams[tID].WrongAnswer[pID]++
			}
		}

		sort.Sort(Teams(teams))

		for _, team := range teams {
			fmt.Println(team.TID, team.Accepted, team.Penalty)
		}
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

C++: #include <stdio.h>
#include <string.h>

typedef struct {
    int ID;
    int penalty;
    int solved;
} set;

set team[51];
int i, j;
int wrong[51][11];
int tID, pID, time;
int T, P, R;
char mes[10];
int count;

int max_solved, min_penalty, winner;

void findfirst(void);

int main(void)
{
    while(1) {
	scanf("%d %d %d", &T, &P, &R);
	if (T == 0) break;
	for (i = 1; i <= T; i++) {
	    team[i].ID = i;
	    team[i].penalty = 0;
	    team[i].solved = 0;
	    for (j = 1; j <= P; j++) {
		wrong[i][j] = 0;
	    }
	}
	for (i = 0; i < R; i++) {
	    scanf("%d %d %d %s", &tID, &pID, &time, mes);
	    if (mes[0] == 'W') {
		wrong[tID][pID]++;
	    } else {
		team[tID].solved++;
		team[tID].penalty += 1200 * wrong[tID][pID] + time;
	    }
	}
	max_solved = T + 1;
	min_penalty = - 1;
	winner = 0;
	for (count = 0; count < T; count++) {
	    findfirst();
	    printf("%d %d %d\n", winner, team[winner].solved, team[winner].penalty);
	    max_solved = team[winner].solved;
	    min_penalty = team[winner].penalty;
	}
    }
    return 0;
}

void findfirst(void)
{
    int winner_solved = -1;
    int winner_penalty = 1200 * 500 + 10800 * 500;
    int winner_team;
    int winner_candidate[51];

    for (i = 1; i <= T; i++) {
	if (team[i].solved > winner_solved && (team[i].solved < max_solved || (team[i].solved == max_solved && team[i].penalty > min_penalty) || (team[i].solved == max_solved && team[i].penalty == min_penalty && i > winner))) {
	    winner_solved = team[i].solved;
	    winner_team = i;
	}
    }
    j = 0;
    for (i = winner_team; i <= T; i++) {
	if (team[i].solved == team[winner_team].solved) {
	    winner_candidate[j] = i;
	    j++;
	}
    }
    for (i = 0; i < j; i++) {
	if (team[winner_candidate[i]].penalty < winner_penalty) {
	    winner_penalty = team[winner_candidate[i]].penalty;
    	    winner = winner_candidate[i];
	}
    }
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

struct P{
int mon[11];
int maru[11];
int pe,x;
int t;
int N;
};

int main(){

struct P Q[50];

int T,P,R;
while(1){
cin>>T>>P>>R;if(T==0&&P==0&&R==0)break;

for(int i=0;i<51;i++)
	{Q[i].x=0;Q[i].t=0;
	for(int j=0;j<11;j++)
	{Q[i].mon[j]=0;Q[i].maru[j]=0;}
}
for(int i=0;i<R;i++){
string str;int ti,pi,tr;

cin>>ti>>pi>>tr;
cin>>str;
if(str=="CORRECT"){
Q[ti].maru[pi]=1;
Q[ti].t+=Q[ti].mon[pi]+tr;
Q[ti].x++;
}

if(str=="WRONG"){
Q[ti].maru[pi]=0;
Q[ti].mon[pi]+=1200;
Q[ti].pe++;
}
}
int jun[51]={};
for(int i=0;i<51;i++)
{jun[i]=i;Q[i].N=i;} 

for(int i=1;i<=T;i++)
for(int j=T;j>i;j--)
{if(Q[jun[j]].x>Q[jun[j-1]].x){int t=jun[j];jun[j]=jun[j-1];jun[j-1]=t;}}


for(int i=1;i<=T;i++)
for(int j=T;j>i;j--)
if(Q[jun[j]].x==Q[jun[j-1]].x&&Q[jun[j-1]].t>Q[jun[j]].t){
int t=jun[j];jun[j]=jun[j-1];jun[j-1]=t;}

for(int i=1;i<=T;i++)
for(int j=T;j>i;j--)
if(Q[jun[j]].x==Q[jun[j-1]].x&&Q[jun[j]].t==Q[jun[j-1]].t&&jun[j]<jun[j-1]){
int t=jun[j];jun[j]=jun[j-1];jun[j-1]=t;}

for(int i=1;i<=T;i++)
{cout<<jun[i]<<" "<<Q[jun[i]].x<<" "<<Q[jun[i]].t<<endl;
}
}
return 0;
}

C++: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> N >> M >> K;
	while (N) {
		vector<pair<pair<int,int>,int>>score(N + 1);
		for (int i = 1; i <= N; i++) {
			score[i].second -= i;
		}
		vector<vector<int>>WA(N + 1, vector<int>(M + 1));
		for (int i = 0; i < K; i++) {
			int a, b, c;
			string s;
			cin >> a >> b >> c >> s;
			if (s[0] == 'C') {
				score[a].first.first++;
				score[a].first.second -= c;
				score[a].first.second -= WA[a][b] * 1200;
			}
			else {
				WA[a][b]++;
			}
		}
		stable_sort(score.begin(), score.end());
		reverse(score.begin(), score.end());
		for (auto i : score) {
			if (i.second) {
				cout << -i.second << " " << i.first.first << " " << -i.first.second << endl;
			}
		}
		cin >> N >> M >> K;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>

using namespace std;

int T[1000], P[1000], R[1000], tID[1000][500], pID[1000][500], Time[1000][500], msg[1000][500], n = 0;

int main() {
	while (cin >> T[n] >> P[n] >> R[n]) {
		if (T[n] == 0)break;
		for (int j = 0; j < R[n]; j++) {
			string messege;
			cin >> tID[n][j] >> pID[n][j] >> Time[n][j] >> messege;
			if (messege == "CORRECT")msg[n][j] = 1;
			else msg[n][j] = 0;
		}
		n++;
	}
	for (int i = 0; i < n; i++) {
		vector<pair<int, int>> AP, temp;
		AP.resize(T[i]);
		int WA[50][10]{ 0 };
		for (int j = 0; j < R[i]; j++) {
			if (msg[i][j] == 0) {
				WA[tID[i][j] - 1][pID[i][j] - 1]++;
			}
			else {
				AP[tID[i][j] - 1].first--;
				AP[tID[i][j] - 1].second += Time[i][j] + WA[tID[i][j] - 1][pID[i][j] - 1] * 1200;
			}
		}
		temp = AP;
		sort(temp.begin(), temp.end());
		int j = 0, k = 0, memo[50]{0};
		while (j < T[i]) {
			if (memo[k] > 0) {
				k++;
				continue;
			}
			if (temp[j] == AP[k]) {
				cout << k + 1 << " " << -temp[j].first << " " << temp[j].second << endl;
				j++;
				memo[k]++;
				k = 0;
			}
			else k++;
		}
	}
	return 0;
}