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

int main(){
  int t,p,r,ha[51][10],tt,mm,ti;
  vector<pair<int,pair<int,int> > > v;
  pair<int,pair<int,int> > vv[50];
  string h;
  while(1){
    cin>>t>>p>>r;
    if(t==0)break;

    for(int i=0;i<=t;i++){
      for(int j=0;j<=p;j++){
	ha[i][j]=0;
      }
    }
    v.clear();
    for(int i=0;i<=t;i++){
      vv[i].first=0;
      vv[i].second.first=0;
      vv[i].second.second=i;
    }

    for(int i=0;i<r;i++){
      cin>>tt>>mm>>ti>>h;
      if(h=="WRONG"){
	ha[tt][mm]++;
      }else {
	vv[tt].second.first+=ha[tt][mm]*1200+ti;
	vv[tt].first--;
      }
    }
    vv[0].first=100;
    for(int i=1;i<=t;i++)v.push_back(vv[i]);
    sort(v.begin() , v.end());
    
    for(int i=0;i<t;i++){
      cout<<v[i].second.second<<" "<<v[i].first*-1<<" "<<v[i].second.first<<endl;
    }
  }
  return 0;
}

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

int main(){
  while(1){
  int T,P,R,t,p,time;
  int ti[51][11]={},pe[51]={};
  string str;
  cin>>T>>P>>R;
  if(T+P+R==0) break;
  int ID[51][11][2]={},ac[51]={};
  for(int i=0;i<R;i++){
    cin>>t>>p>>time>>str;
    if(str=="WRONG") ID[t][p][0]++;
    else{
 ID[t][p][1]++;
 ac[t]++;
 ti[t][p]=time;
    }    
  }
  int ans[51],q;
  for(int i=1;i<=T;i++)
    for(int j=1;j<=P;j++)if(ID[i][j][1]==1)pe[i]+=ID[i][j][0]*1200+ti[i][j];
 
  for(int i=1;i<=T;i++) ans[i]=i;
  for(int i=1;i<=T-1;i++)
    for(int j=i+1;j<=T;j++){
      if(ac[ans[i]]<ac[ans[j]] || (ac[ans[i]]==ac[ans[j]] && pe[ans[i]]>pe[ans[j]])){
	q=ans[i];
	ans[i]=ans[j];
	ans[j]=q;
      }else if(ac[ans[i]]==ac[ans[j]] && ans[i]>ans[j] && pe[ans[i]]==pe[ans[j]]){
	  q=ans[i];
	  ans[i]=ans[j];
	  ans[j]=q;
	}
    }
  for(int i=1;i<=T;i++) cout<<ans[i]<<' '<<ac[ans[i]]<<' '<<pe[ans[i]]<<endl;
  }

  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int t,p,r;
	while(cin >> t >> p >> r,t){
		int tid,pid,time;
		string message;
		vector <pair <int,pair<int,int> >  >pen(t);
		for(int i=0;i<t;i++)
			pen[i].second.second=i+1;
		int wor[t][p];
		int done[t][p];
		for(int i=0;i<t;i++)
			for(int j=0;j<p;j++){
				wor[i][j]=0;
				done[i][j]=0;
			}
		for(int i=0;i<r;i++){
			cin >> tid >> pid >> time >> message;
			tid--; pid--;
			if(done[tid][pid]==1);
			else{
				if(message[0]=='W')
					wor[tid][pid]++;
				else{
					pen[tid].second.first+=wor[tid][pid]*1200+time;
					pen[tid].first++;
					done[tid][pid]=1;
				}
			}
		}
		sort(pen.begin(),pen.end());
		for(int i=0;i<t-1;i++){
			for(int j=i+1;j<t;j++){
				if(pen[i].first<pen[j].first){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t-1;i++){
			for(int j=i+1;j<t;j++){
				if(pen[i].second.first==pen[j].second.first&&pen[i].second.second>pen[j].second.second){
					swap(pen[i].first,pen[j].first);
					swap(pen[i].second.first,pen[j].second.first);
					swap(pen[i].second.second,pen[j].second.second);
				}
			}
		}
		for(int i=0;i<t;i++){
			cout << pen[i].second.second << " " << pen[i].first << " " << pen[i].second.first << endl;
		}
	}
}

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 = 0;
    for (i = winner_team; i <= T; i++) {
	if (team[i].solved == team[winner_team].solved) {
	    if (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_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];
	}
    }
}