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<cstring>

using namespace std;
typedef struct{
  int teamnum;
  int solve;
  int stime;
}TEAM;

const int MAXTEAM = 51;
const int MAXPROBLEM = 11;
TEAM team[MAXTEAM];
int T,P,R;
int wrong[MAXTEAM][MAXPROBLEM];


void init(){
  for(int i = 1; i < MAXTEAM; i++){
    team[i].teamnum = i;
    team[i].solve = team[i].stime = 0;
  }
  memset(wrong,0,sizeof(wrong));
}


void solve(int tID,int pID,int solvetime){
  team[tID].solve++;
  team[tID].stime += wrong[tID][pID]*1200+solvetime;
}


void teamsort(){
  for(int i = 1; i <= T; i++)
    for(int j = i+1; j <= T; j++)
      if(team[i].solve < team[j].solve) swap(team[i],team[j]);
      else if(team[i].solve == team[j].solve)
	if(team[i].stime > team[j].stime) swap(team[i],team[j]);
	else if(team[i].stime == team[j].stime)
	  if(team[i].teamnum > team[j].teamnum) swap(team[i],team[j]);

}

void print(){
  for(int i = 1; i <= T; i++)
    cout << team[i].teamnum << " " << team[i].solve << " "<< team[i].stime << endl;

}
int main(){
  int tID,pID,solvetime;
  string judge;

  while(cin >> T >> P >> R && T+P+R){
    init();
    for(int i = 0; i < R; i++){
      cin >> tID >> pID >> solvetime >> judge;
      if(judge == "WRONG") wrong[tID][pID]++;
      else solve(tID,pID,solvetime);
    }
    teamsort();
    print();
  }
}

C++: #include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <tuple>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

bool compare(const tuple<int,int,int> &a, const tuple<int,int,int> &b){
	if(get<0>(a) == get<0>(b)){
			if(get<1>(a) == get<1>(b)){
				return get<2>(a) < get<2>(b);
			}
			return get<1>(a) < get<1>(b);
		}
		return get<0>(a) > get<0>(b);
}
			
int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<tuple<int,int,int> > inf_team(t,tuple<int,int,int>(0,0,0));//problem,time,number
		REP(i,t)get<2>(inf_team[i]) = i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				get<1>(inf_team[t_id]) += time + 1200*penalty[t_id][p_id];
				get<0>(inf_team[t_id])++;
			}
		}
		sort(inf_team.begin(),inf_team.end(),compare);
		REP(i,t){
			cout << get<2>(inf_team[i]) + 1 << " " << get<0>(inf_team[i]) << " " << get<1>(inf_team[i]) << endl;
		}
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;



int main()
{
	int t, p, r;
	while(1){
		cin >> t >> p >> r;
		if(t == 0 && t == 0 && r == 0) break;
		vector<pair<int, pair<int, int> > > score(60);
		// score.first が正解数、(score.second).firstがペナルティ、(score.second).secondがチーム番号
		int wrong[60][11] = {0};
		// 誤答数[チーム番号][問題番号]
		for(int i = 0; i <= t; i++){
			score[i].first = 0;
			(score[i].second).first = 0;
			(score[i].second).second = i + 1;
		}
		int team_r, problem_r, time_r;
		string message_r;
		for(int i = 0; i < r; i++){
			cin >> team_r >> problem_r >> time_r >> message_r;
			if(message_r == "CORRECT"){
				score[team_r-1].first--;
				(score[team_r-1].second).first += 1200 * wrong[team_r-1][problem_r] + time_r;
			} else if(message_r == "WRONG"){
				wrong[team_r-1][problem_r]++;
			}
		}
		sort(score.begin(), score.begin() + t);
		for(int i = 0; i < t; i++){
			cout << (score[i].second).second << ' ' << -(score[i].first) << ' ' << (score[i].second).first << endl;
		}
	}
	return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main(){
	int t,p,r;
	string mestype[2] = {"WRONG","CORRECT"};
	while(true){
		cin >> t >> p >> r;
		if( !t && !p && !r){
			break;
		}
		int teams_no[50];
		int teams[50]; // 点数
		int teams_c[50];
		int teams_p[50]; // ペナルティ
		int teams_w[10][50]; // ><;
		for(int i = 0; i < t; i++){
			teams[i] = 0;
			teams_c[i] = 0;
			teams_p[i] = 0;
			teams_no[i] = i + 1;
		}
		for(int i = 0; i < p; i++){
			for(int j = 0; j < t; j++){
				teams_w[i][j] = 0;
			}
		}
		
		
		int teams_in;
		for(int i = 0; i < r; i++){
			int pno, time;
			string mes;
			cin >> teams_in >> pno >> time;
			cin >> mes;
			if(mes == mestype[0]){
				teams_w[pno - 1][teams_in - 1]++;
			}
			else{
				teams_c[teams_in - 1]++;
				teams_p[teams_in - 1] += teams_w[pno - 1][teams_in - 1] * 1200 + time;
				teams[teams_in - 1] += 100000000 - teams_p[teams_in - 1];
			}
		}
		
		for(int i = 0 ; i < t - 1; i++){
			for(int j = i + 1 ; j < t; j++){
				if(teams[i] < teams[j]){
					swap(teams[i], teams[j]);	
					swap(teams_no[i], teams_no[j]);
					swap(teams_p[i], teams_p[j]);
					swap(teams_c[i], teams_c[j]);
				}
			}
		}
		for(int i = 0 ; i < t ; i++){
			for(int j = 0 ; j < t; j++){
				if(teams[i] == teams[j]){
				if(teams_p[i] == teams_p[j]){
					if(teams_no[i] < teams_no[j]){
						swap(teams[i], teams[j]);	
						swap(teams_no[i], teams_no[j]);
						swap(teams_p[i], teams_p[j]);	
						swap(teams_c[i], teams_c[j]);
					}	
				}
				}
			}
		}
		for(int i = 0; i < t; i++){
			printf("%d %d %d\n", teams_no[i], teams_c[i], teams_p[i]);
		}
	}
	return 0;
}