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 = 1;
    winner_candidate[0] = winner_team;
    for (i = winner_team + 1; i <= T; i++) {
	if (team[i].solved == team[winner_team].solved) {
	    if ((team[i].penalty == min_penalty && i > winner) || team[i].penalty > min_penalty) {
	        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 <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

class St{
public:
  int td, sc, pn, ac;

  St() {}
  St(int _td, int _sc, int _pn, int _ac): td(_td), sc(_sc), pn(_pn), ac(_ac) {}

  void print(){
    cout << td << " " << ac << " " << sc << endl;
  }
};

int t, r, p;

bool comp(const St& s1, const St& s2)
{
  if(s1.ac == s2.ac){
    if(s1.sc == s2.sc) return s1.td < s2.td;
    return s1.sc < s2.sc;
  }

  return s1.ac > s2.ac;
}

int main()
{
  string str;
  vector<St> vec;
  int td, pd, tm;
  bool a[51][11];
  int sv[51][11];

  while(cin>>t>>r>>p && t+r+p){
    for(int i = 0; i < t; ++i) vec.push_back(St(i+1, 0, 0, 0));
    fill(&a[0][0], &a[51][0], false);
    fill(&sv[0][0], &sv[51][0], 0);

    while(p--){
      cin >> td >> pd >> tm >> str;
      if(a[td][pd]) continue;

      if(str == "CORRECT"){
	a[td][pd] = true;
	++vec[td-1].ac;
	vec[td-1].sc += (tm+1200*sv[td][pd]);
      } else {
	++sv[td][pd];
	++vec[td-1].pn;
      }
    }
    sort(vec.begin(), vec.end(), comp);

    for(int i = 0; i < vec.size(); ++i)
      vec[i].print();

    vec.clear();
  }

  return 0;
}

C++: #include <algorithm>
#include <cstdio>
#include <map>
#include <string>
#include <tuple>
#include <vector>

const std::string wrong("WRONG");

int main() {
    int T, P, R;
    while (scanf("%d %d %d", &T, &P, &R) != EOF) {
        if (T == 0 && P == 0 && R == 0)
            break;
        
        std::map<int, std::map<int, long long int>> wrong_v;
        std::map<int, int> right_v;
        std::map<int, int> penalty_v;

        int tID, pID, time;
        char result[8];
        for (int i = 0; i < R; ++i) {
            scanf("%d %d %d %s", &tID, &pID, &time, result);
            if (result == wrong) {
                ++wrong_v[tID][pID];
            } else {
                ++right_v[tID];
                penalty_v[tID] += wrong_v[tID][pID] * 1200 + time;
            }
        }
        
        std::map<int, std::vector<std::tuple<long long int, int>>> rank;
        for (int i = 1; i <= T; ++i) {
            rank[right_v[i]].push_back(std::make_tuple(penalty_v[i], i));
        }
        for (auto it = rank.rbegin(); it != rank.rend(); ++it) {
            if (it->second.size() > 1) {
                std::sort(it->second.begin(), it->second.end());
            }
            for (auto i : it->second) {
                printf("%d %d %lld\n", std::get<1>(i), it->first, std::get<0>(i));
            }
        }
    }
}