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 "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;

struct team {
	int id;
	int solve;
	int score;
	bool operator< (const team&t) {
		return solve == t.solve?score == t.score ?id>t.id:score>t.score: solve < t.solve;
	}
};

int main() {
	while(1) {
		int T, P, R; cin >> T >> P >> R;
		vector<vector<int>>miss(T, vector<int>(P));
		vector<vector<int>>scores(T, vector<int>(P));
		if (!T)break;
		for (int i = 0; i < R; ++i) {
			int tid, pid, time;string mes; cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT") {
				if (!scores[tid][pid])
					scores[tid][pid] = 1200 * miss[tid][pid] + time;

			}
			else {
				miss[tid][pid]++;
			}
		}
		vector<team>performs(T);

		for (int i = 0; i < T; ++i) {
			performs[i].id = i + 1;
			for (int j = 0; j < P; ++j) {
				if (scores[i][j]) {
					performs[i].solve++;
					performs[i].score += scores[i][j];
				}
			}
		}
		sort(performs.begin(), performs.end());
		reverse(performs.begin(), performs.end());
		for (int i = 0; i < T; ++i) {
			cout << performs[i].id << " " << performs[i].solve << " "<<performs[i].score << endl;
		}
	}

	
	return 0;
}

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[52];

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 <bits/stdc++.h>

#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;

int main()
{
    int t, p, r;
    while (cin >> t >> p >> r, t) {
        vector<vector<int>> result(t, vector<int>(3+p,0));
        loop (t, i) result[i][0] = i+1;
        loop (r, i) {
            int tid, pid, time;
            string msg;
            cin >> tid >> pid >> time >> msg;
            if (msg == "CORRECT") {
                if (result[tid-1][pid+2] != -1) {
                    result[tid-1][1]++;
                    result[tid-1][2] += result[tid-1][pid+2]*1200 + time;
                    result[tid-1][pid+2] = -1;
                }
            } else {
                if (result[tid-1][pid+2] != -1)
                    result[tid-1][pid+2]++;
            }
        }
        sort(all(result),
                [](vector<int> a, vector<int> b) {
                    if (a[1] != b[1]) return a[1] > b[1];
                    if (a[2] != b[2]) return a[2] < b[2];
                    return a[0] < b[0];
                });
        for (auto t : result)
            cout << t[0] << ' ' << t[1] << ' ' << t[2] << endl;
    }
}