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<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

int miss[55][11];
int penalty[55];
int correct[55];

bool comp(const int& a, const int& b) {
    if (correct[a] != correct[b]) return correct[a] > correct[b];
    else {
        if (penalty[a] != penalty[b]) return penalty[a] < penalty[b];
        else return a < b;
    }
}

void solve(int t, int p, int r) {
    for (int i = 0; i < t; i++) {
        penalty[i] = 0;
        correct[i] = 0;
        for (int j = 0; j < p; j++) {
            miss[i][j] = 0;
        }
    }
    int tid, pid, now_time;
    string message;
    for (int i = 0; i < r; i++) {
        cin >> tid >> pid >> now_time >> message;
        tid--, pid--;
        if (message == "WRONG") {
            miss[tid][pid]++;
        }
        else {
            correct[tid]++;
            penalty[tid] += miss[tid][pid] * 1200 + now_time;
        }
    }
    vector<int> ans(t);
    for (int i = 0; i < t; i++) ans[i] = i;
    sort(ans.begin(), ans.end(), comp);
    for (int i = 0; i < t; i++) {
        cout << ans[i] + 1 << ' ' << correct[ans[i]] << ' ' << penalty[ans[i]] << endl;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T, P, R;
    while (true) {
        cin >> T >> P >> R;
        if (T == 0 && P == 0 & R == 0) break;
        solve(T, P, R);
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
using namespace std;

struct info
{
    int Team;
    int solved;
    int penalty;
    int mis[10];
    info(int x, int y, int z)
    {
        Team = x;
        solved = y;
        penalty = z;
        for (int i = 1; i <= 10; i++)
        {
            mis[i - 1] = 0;
        }
    }
};

bool asc(info const &left, info const &right)
{
    if (left.solved != right.solved)
        return left.solved > right.solved;
    else if (left.penalty != right.penalty)
        return left.penalty < right.penalty;
    else
        return left.Team < right.Team;
}

int main()
{
    while (true)
    {
        int t = 0, p = 0, r = 0;
        cin >> t >> p >> r;
        if (t == 0 && p == 0 && r == 0)
            break;

        vector<info> InfoList;
        for (int i = 1; i <= t; i++)
        {
            info x = info(i, 0, 0);
            InfoList.push_back(x);
        }
        // cout << "Before" << endl;
        // for (int i = 1; i <= t; i++)
        // {
        //     cout << InfoList[i - 1].Team << " " << InfoList[i - 1].solved << " " << InfoList[i - 1].penalty << endl;
        // }

        for (int i = 0; i < r; i++)
        {
            int tID, pID, t;
            string m;
            cin >> tID >> pID >> t >> m;

            if (m == "CORRECT")
            {
                InfoList[tID - 1].solved++;
                InfoList[tID - 1].penalty += InfoList[tID].mis[pID - 1] * 1200 + t;
            }
            if (m == "WRONG")
            {
                InfoList[tID].mis[pID - 1]++;
            }
        }

        sort(InfoList.begin(), InfoList.end(), asc);

        // cout << "after" << endl;
        for (int i = 1; i <= t; i++)
        {
            cout << InfoList[i - 1].Team  << InfoList[i - 1].solved << InfoList[i - 1].penalty << endl;
        }
    }

    return 0;
}

C++: #include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

struct team{
  int ans,id,p[10],pena;
  bool operator<(const team &a)const{
    if(this->ans == a.ans){
      return this->pena < a.pena;
    }else{
      return this->ans > a.ans;
    }
  }
};

int main(){
  int t,p,r;
  while(cin>>t>>p>>r){
    if(t==0)break;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,pid,tm;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT"){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
      }else{
	T[tid].p[pid]++;
      }
    }
    sort(T,T+t);
    for(int i=0;i<t;i++)
      cout << T[i].id << " " << T[i].ans << " " << T[i].pena << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <cstdio>
#include <istream>
#include <sstream>
#include <iomanip>
using namespace std;

typedef ostringstream oss;
typedef istringstream iss;

const int PENALTY_TIME = 1200;
struct Team{
	Team(int quesNum) : acceptCnt(0), penalty(0) {
		wrongCnt.resize(quesNum, 0);
	}
	int id;
	int acceptCnt;
	int penalty;
	vector<int> wrongCnt;
};

bool TeamLess(const Team& t1, const Team& t2) {
	if (t1.acceptCnt != t2.acceptCnt) {
		return t1.acceptCnt < t2.acceptCnt;
	}
	if (t1.penalty != t2.penalty) {
		return t1.penalty > t2.penalty;
	}
	return t1.id > t2.id;
}


int main(void) {
	int teamNum, quesNum, recordNum;
	while (cin >> teamNum >> quesNum >> recordNum, teamNum) {
		vector<Team> teams(teamNum, quesNum);
		for (int i = 0; i < teamNum; i++) {
			teams[i].id = i + 1;
		}

		int tID, qID, time;
		string mes;
		for (int i = 0; i < recordNum; i++) {
			cin >> tID >> qID >> time >> mes;
			tID--; qID--;
			if (mes == "CORRECT") {
				teams[tID].acceptCnt++;
				teams[tID].penalty += teams[tID].wrongCnt[qID] * PENALTY_TIME + time;
			}else {
				teams[tID].wrongCnt[qID]++;
			}
		}

		sort(teams.rbegin(), teams.rend(), TeamLess);

		for (int i = 0; i < teams.size(); i++) {
			printf("%d %d %d\n",
				teams[i].id, teams[i].acceptCnt, teams[i].penalty);
		}
	}

	return 0;
}