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>
using namespace std;

struct Team{
  int team_num,correct,time;

};

int main(){
  Team data[51];
  int T,P,R,i,j,team_wrong[51][11],t,p,jikan;
  string message;
  while(1){
  cin >> T >> P >> R;
  if( T == 0 && P == 0 && R == 0 ) break;
  for( i = 1; i <= T; i++ ) data[i].team_num = i;
  for( i = 1; i <= T; i++ ) data[i].time = 0;
  for( i = 1; i <= T; i++ ) data[i].correct = 0;
  for( i = 1; i <= 50; i++ ){
    for( j = 1; j <= 10; j++ ){
      team_wrong[i][j] = 0;
    }
  }
  for( i = 0; i < R; i++ ){
    cin >> t >> p >> jikan >> message;
    if( message == "CORRECT" ){
      data[t].correct++;
      data[t].time += jikan + team_wrong[t][p] * 1200;
    }else if( message == "WRONG" ){
      team_wrong[t][p]++;
    }
  }

  for( i = 1; i <=T; i++ ){
    for( j = 1; j < T; j++ ){
      if( data[j].time > data[j+1].time ) swap( data[j],data[j+1] );
    }
  }

  for( i = 1; i <=T; i++ ){
    for( j = 1; j < T; j++ ){
      if( data[j].correct < data[j+1].correct ) swap( data[j],data[j+1] );
    }
  }

  for( i = 1; i <= T; i++ )
    cout << data[i].team_num << " " 
	 << data[i].correct << " " << data[i].time << endl;
  }

  return 0;
}

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

using namespace std;

struct Team {
	int tid, correct, penalty;

	Team() {}
	Team(int tid, int correct, int penalty) : tid(tid), correct(correct), penalty(penalty) {}
};
bool operator >(const Team& t1, const Team& t2) {
	if (t1.correct == t2.correct) return t1.penalty == t2.penalty ? t1.tid < t2.tid : t1.penalty < t2.penalty;
	else return t1.correct > t2.correct;
}

int main() {
	int T, P, R;
	while ( cin >> T >> P >> R, T || P || R ) {
		int correct[50] = {0}, wrong[50][10] = {0};
		bool solved[50][10] = {0};
		int penalty[50] = {0};
		for (int i = 0; i < R; ++i) {
			int tid, pid, time; string message; cin >> tid >> pid >> time >> message;
			--tid, --pid;
			if (!solved[tid][pid]) {
				if (message == "CORRECT") {
					++correct[tid];
					penalty[tid] += wrong[tid][pid] * 1200 + time;
					solved[tid][pid] = true;
				}
				else {
					++wrong[tid][pid];
				}
			}
		}

		vector<Team> v(T);
		for (int i = 0; i < T; ++i) {
			v[i] = Team(i+1, correct[i], penalty[i]);
		}
		sort( v.begin(), v.end(), greater<Team>() );

		for (int i = 0; i < T; ++i) {
			cout << v[i].tid << " " << v[i].correct << " " << v[i].penalty << endl;
		}
	}
}

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

using namespace std;

class info {
public:
    int tid;
    int pen;
    int cor;
    int p[10];
    info() {
        tid = 0;
        pen = 0;
        cor = 0;
        for (int i = 0; i < 10; i++)
            p[i] = 0;
    }
};

bool cmp(const class info &a, const class info &b)
{
    return (a.cor > b.cor) || (a.cor == b.cor && a.pen < b.pen) ||
        (a.cor == b.cor && a.pen == b.pen && a.tid < b.tid);
}

int main()
{
    int t, p, r;

    while (cin >> t >> p >> r, t || p || r) {
        info m[50];

        for (int i = 0; i < t; i++)
            m[i].tid = i + 1;

        for (int i = 0; i < r; i++) {
            int tid, pid, tm;
            string mes;

            cin >> tid >> pid >> tm >> mes;

            if (mes == "WRONG") 
                m[tid - 1].p[pid - 1]++;
            else if (mes == "CORRECT") {
                m[tid - 1].pen = m[tid - 1].p[pid - 1] * 1200 + tm;
                m[tid - 1].cor += 1;
            }
        }

        sort(m, m + t, cmp);

        for (int i = 0; i < t; i++)
            cout << m[i].tid << " " << m[i].cor << " " << m[i].pen << endl;
    }

    return 0;
}

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

using namespace std;

struct Team {
    int id, p, s;
    vector<int> wrong;
    Team(int _id, int num) : id(_id), wrong(num, 0), p(0), s(0) { }
    bool operator <(const Team& t) const {
        if(s != t.s) return s > t.s;
        if(p != t.p) return p < t.p;
        return id < t.id;
    }

    void solve(int pid, int t) {
        s++;
        p += wrong[pid] * 1200 + t;
    }
};

int main() {
    for(int T, P, R; cin >> T >> P >> R, T + P + R > 0; ) {
        vector<Team> teams(T, Team(0, P));
        for(int i = 0; i < T; i++) {
            teams[i].id = i + 1;
        }
        for(int i = 0; i < R; i++) {
            int tid, pid, tm; string res; cin >> tid >> pid >> tm >> res;
            tid--, pid--;
            if(res == "CORRECT") {
                teams[tid].solve(pid, tm);
            }
            else {
                teams[tid].wrong[pid]++;
            }
        }
        sort(teams.begin(), teams.end());
        for(int i = 0; i < T; i++) {
            cout << teams[i].id << ' ' << teams[i].s << ' ' << teams[i].p << endl;
        }
    }
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>

using namespace std;


struct st{
	int num;
	int point;
	int penalty;
	vector<int> wrong;
	
	st(){}
	st(int n){
		point = 0;
		penalty = 0;
		for(int i=0;i<n;i++){
			wrong.push_back(0);
		}
	}
	
	void setnum(int k){
		num = k;
	}
	
	bool operator < (const st &a) const{
		return this->point == a.point ? 
		(this->penalty == a.penalty ? this->num > a.num : this->penalty > a.penalty)
		: this->point < a.point;
	}
};



bool solve(){
	int t,p,r;
	cin>> t>> p>> r;
	if(t==0&&p==0&&r==0) return false;
	
	vector<st> s(t,st(p));
	for(int i=0;i<s.size();i++){
//		s[i].num = i+1;
		s[i].setnum(i+1);
	}
	
	for(int i=0;i<r;i++){
		int a, b ,c;
		string str;
		cin>> a>> b>> c>> str;
		a--; b--;
		if(str == "WRONG"){
			s[a].wrong[b]++;
		}else{
			s[a].point++;
			s[a].penalty += s[a].wrong[b] * 1200 + c;
		}
	}
	
	sort(s.rbegin(), s.rend());
	for(int i=0;i<s.size();i++){
		cout<< s[i].num<< " "<< s[i].point<< " "<< s[i].penalty<< endl;
	}
		
	return true;
	
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	while(solve());

	return 0;
}