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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int t, p, r;
    while(cin >> t >> p >> r, t+p+r){
        bool correct[t][r];
        int submit[t][r];
        int penalty[t][r];
        rep(i, t)rep(j, r){penalty[i][j] = 0; submit[i][j] = 0; correct[i][j] = false;}
        rep(k, r){
            int team, problem, time;
            string message;

            cin >> team >> problem >> time >> message;
            team--; problem--;

            if(message == "CORRECT"){
                correct[team][problem] = true;
                penalty[team][problem] += submit[team][problem]*1200+time;
            }
            submit[team][problem]++;
        }

        vector<pair<int, pair<ll, int> > > v(t);
        rep(i, t){
            ll ca = 0, pn = 0;
            rep(j, p){
                if(correct[i][j])ca++;
                pn += penalty[i][j];
            }
            v[i] = mp(ca, mp(inf-pn, 100-i));
        }
        sort(all(v));

        for(int i=t-1; 0 <= i; i--){
            cout << 100- v[i].second.second+1 << " " << v[i].first << " " << inf-v[i].second.first << endl;
        }
    }
}

C++: #include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

#define PENALTY 1200
#define SIZE 15
#define MAXT 55

using namespace std ;

struct Data
{
	int Tid ;
	int Pid ;
	int Time ;
	char mess[20] ;
} ;

struct Team
{
	int idx ;
	int score ;
	int penalty ;
	int wrong[SIZE] ;
	Team ( )
	{
		score = penalty = 0 ;
		memset ( wrong , 0 , SIZE * sizeof ( int ) ) ;
	}
	bool operator < ( const struct Team &a ) const
	{
		return ( score > a.score ) || ( ( score == a.score && ( penalty < a.penalty || ( penalty == a.penalty && idx < a.idx ) ) ) ) ;
	}
} ;

struct Data *input ;
struct Team *arr ;

char const wr[] = "WRONG" ;
char const co[] = "CORRECT" ;

int tc ;
int pc ;
int rc ;

void init ( ) ;
void dispose ( ) ;

int main ( )
{
	while ( scanf ( "%d %d %d" , &tc , &pc , &rc ) == 3 && ( tc || pc || rc ) ) {
		init ( ) ;
		while ( rc-- ) {
			scanf ( "%d %d %d %s" , &( input -> Tid ) , &( input -> Pid ) , &( input -> Time ) , input -> mess ) ;
			if ( strcmp ( input -> mess , wr ) == 0 ) {
				arr[input -> Tid].wrong[input -> Pid]++ ;
			}
			else {
				arr[input -> Tid].score++ ;
				arr[input -> Tid].penalty += ( input -> Time + arr[input -> Tid].wrong[input -> Pid] * PENALTY ) ;
			}
		}
		sort ( arr + 1 , arr + tc + 1 ) ;
		for ( int i = 1 ; i <= tc ; i++ ) {
			printf ( "%d %d %d\n" , arr[i].idx , arr[i].score , arr[i].penalty ) ;
		}
		dispose ( ) ;
	}
	return 0 ;
}

void init ( )
{
	input = new struct Data ;
	arr = new struct Team [MAXT] ;
	for ( int i = 0 ; i < MAXT ; i++ ) {
		arr[i].idx = i ;
	}
}

void dispose ( )
{
	delete input ;
	delete [] arr ;
}

C++: #include<bits/stdc++.h>
#define I 900000
using namespace std;
int x[99],z[99],y[99][20],h[100],a,b,c,d,e,f,i,j,k;string S;
int main(){
	while(true){
		for(i=0;i<99;i++){x[i]=I;}
		memset(y,0,sizeof(y));
		memset(h,0,sizeof(h));
		cin>>a>>b>>c;
		if(a==0){break;}
		for(i=0;i<c;i++){
			cin>>d>>e>>f>>S;
			if(S[0]=='W'){
				y[d][e]++;
			}
			else{
				x[d]+=I;
				x[d]-=f+1200*y[d][e];
			}
		}
		for(i=1;i<=a;i++){z[i]=x[i];}
		sort(x+1,x+a+1);
		for(i=a;i>=1;i--){
			for(j=1;j<=a;j++){
				if(z[j]==x[i]&&h[j]==0){
					cout<<j<<' '<<(x[i]+I-1)/I-1<<' '<<(100*I-x[i])%I<<endl;
					h[j]=1;
				}
			}
		}
	}
}

C++: #include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int T, P, R;
	while (cin >> T >> P >> R) {
		if (T == 0 && P == 0 && R == 0) {
			break;
		}
		int team[50][10] = {0};
		int pena[50][2] = {0};
		for (int i = 0; i < R; i++) {
			int tid, pid, time;
			string message;
			cin >> tid >> pid >> time >> message;
			if (message == "CORRECT") {
				pena[tid-1][0]++;
				pena[tid-1][1] += team[tid-1][pid-1] * 1200 + time;
			} else {
				team[tid-1][pid-1]++;
			}
		}
		int juni[50];
		for (int i = 0; i < T; i++) {
			juni[i] = i+1;
		}
		for (int i = 0; i < T; i++) {
			for (int j = T-1; j > i; j--) {
				if (pena[j][0] < pena[j-1][0]) {
					swap(pena[j][0], pena[j-1][0]);
					swap(pena[j][1], pena[j-1][1]);
					swap(juni[j], juni[j-1]);
				} else if (pena[j][0] == pena[j-1][0]) {
					if (pena[j][1] > pena[j-1][1]) {
						swap(pena[j][0], pena[j-1][0]);
						swap(pena[j][1], pena[j-1][1]);
						swap(juni[j], juni[j-1]);
					}
				} 
			}
		}
		for (int i = 0; i < T; i++) {
			cout << juni[i] << ' ' << pena[i][0] << ' ' << pena[i][1] << endl;
		}
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define I 900000
int x[99],z[99],y[99][20],h[99],a,b,c,d,e,f,i,j,k;string S;
int main(){
while(true){
for(i=0;i<99;i++){x[i]=I;}
memset(y,0,sizeof(y));
memset(h,0,sizeof(h));
std::cin>>a>>b>>c;
if(a==0){break;}
for(i=0;i<c;i++){
std::cin>>d>>e>>f>>S;
if(S[0]=='W'){
y[d][e]++;
}
else{
x[d]+=I;
x[d]-=f+1200*y[d][e];
}
}
for(i=1;i<=a;i++){z[i]=x[i];}
sort(x+1,x+a+1);
for(i=a;i>=1;i--){
for(j=1;j<=a;j++){
if(z[j]==x[i]&&h[j]==0){
printf("%d %d %d\n",j,(x[i]+I-1)/I-1,(99*I-x[i])%I);
h[j]=1;
}
}
}
}
}