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++: //
//  main.cpp
//  c
//
//  Created by 13B10694 on 2015/06/01.
//  Copyright (c) 2015????´ 13B10694. All rights reserved.
//

#include <iostream>
#include <vector>
#include<stdio.h>
#include <algorithm>
#include<string.h>
using namespace std;

int now=1;

class team{
    
public:
    int id, pen, sol;
    int wrong[12];
    vector <int> solved;
    team(){
        memset(wrong, 0, sizeof(wrong));
        id=now++;
        pen=0;sol=0;
    }
    ~team(){
        solved.clear();
    }
    
    bool operator < (const team& b) const
    {
        return solved.size()==b.solved.size() ? pen== b.pen ? id<b.id : pen<b.pen : solved.size()>b.solved.size();
    }
};

int main() {
    int t,p,r;
    while(cin>>t>>p>>r,t){
        now=1;
        vector<team> tea(t);

        for(int i=0;i<r;i++){
            int ti, pi, tim;
            string mes;
            cin>>ti>>pi>>tim>>mes;
            ti-=1;
            if(mes=="WRONG"){
                tea[ti].wrong[pi]++;
                continue;
            }
            if(find(tea[ti].solved.begin(),tea[ti].solved.end(),pi)!=tea[ti].solved.end()){
                continue;
            }
            tea[ti].solved.push_back(pi);
            tea[ti].pen += tea[ti].wrong[pi]*1200+tim;
  
        }
        sort(tea.begin(),tea.end());
        for(int i=0;i<t;i++){
            cout<<tea[i].id<<" "<<tea[i].solved.size()<<" "<<tea[i].pen<<endl;
        }
       tea.clear();
    }
    
    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;
	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};
		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 (message == "CORRECT") {
				++correct[tid];
				penalty[tid] += wrong[tid][pid] * 1200 + time;
			}
			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++: #define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#include <bitset>
using namespace std;
const int INF=1<<30;

typedef pair<int,int> P;



int main(){
	
	int t,p,r;
	while(cin>>t>>p>>r,t!=0&&p!=0&&r!=0){
		vector< P > team(t);
		int problem[51][11]={0};
		int a,b,c;
		string s;
		for(int i=0;i<r;i++){
			cin>>a>>b>>c>>s;
			if(s=="WRONG"){
				problem[a][b]++;
			}
			else {
				team[a-1].first++;
				team[a-1].second+=problem[a][b]*1200+c;
			}
		}
		int q=t;
		while(q--){
		int k=0;
		int maxp=-1,maxtime=-1;
		for(int i=0;i<t;i++){
			if(maxp<team[i].first){
				k=i+1;
				maxp=team[i].first;
				maxtime=team[i].second;
			}
			else if(maxp==team[i].first&&maxtime>team[i].second){
				k=i+1;
				maxtime=team[i].second;
				
			}
		}
			cout<<k<<" "<<maxp<<" "<<maxtime<<endl;
			team[k-1].first=-100;
		
	}
	}
	
	

}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 51;
typedef pair<int,int> PP;
typedef pair<int,PP> P;

int main(){
  int t,p,r,tID,pID,time;
  string judge;

  while(cin >> t >> p >> r ,t + p + r){
    int ans[MAX][MAX] = {{0}},pe[MAX][MAX] = {{0}},AC[MAX]={0};
    while(r--){
      cin >> tID >> pID >> time >> judge;

      if(judge == "CORRECT"){
	ans[tID][pID] += time+pe[tID][pID];
	AC[tID]++;
      }
      else{
	pe[tID][pID] += 1200;
      }
    }

    vector<P> v(t);
    for(int i = 0 ; i < t ; i++){
      for(int j = 0 ; j < p ; j++){
	v[i].second.first += ans[i+1][j+1];
      }
      v[i].first = -AC[i+1];
      v[i].second.second = i+1;
    }
    sort(v.begin(),v.end());
    for(int i = 0 ; i < t ; i++){
      cout << v[i].second.second << ' ' << -v[i].first 
	   << ' ' << v[i].second.first << endl; 
    }
  }

  return 0;
}

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

using namespace std;

class Info{
public:
	int id, ac, penalty;
	Info(int i=0, int a=0, int p=0) : id(i), ac(a), penalty(p) {}
	bool operator < (const Info& i) const {
		if(ac != i.ac) return ac > i.ac;
		if(penalty != i.penalty) return penalty < i.penalty;
		return id < i.id;
	}
};

int main(){
	int cnt[50][10];
	int T, P, R;
	while(cin >> T >> P >> R && T){
		for(int i=0;i<T;i++){
			for(int j=0;j<P;j++){
				cnt[i][j] = 0;
			}
		}
		vector<Info> vi(T);
		for(int i=0;i<T;i++) vi[i].id = i+1;
		for(int i=0;i<R;i++){
			int tID, pID, time;
			string message;
			cin >> tID >> pID >> time >> message;
			tID--; pID--;
			if(cnt[tID][pID] == -1) continue;
			if(message == "CORRECT"){
				vi[tID].ac++;
				vi[tID].penalty += time + 1200*cnt[tID][pID];
				cnt[tID][pID] = 0;
			} else {
				++cnt[tID][pID];
			}
		}
		sort(vi.begin(), vi.end());
		for(Info in : vi){
			cout << in.id << " " << in.ac << " " << in.penalty << endl;
		}
	}
}