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<stdio.h>
typedef struct{
  int TID;
  int TT;
  int Time;
}T;

T team[51],tmp;

int main()
{
  int i,j,T,P,R,ID,PID,Ti;
  int PP[51][11];
  char S[10];
  while(1){
    scanf("%d%d%d",&T,&P,&R);
    if(T==0&&P==0&&R==0)break;
    for(i=1;i<T+1;i++){
      team[i].TID=i;
      team[i].TT=0;
      team[i].Time=0;
      for(j=0;j<10;j++)PP[i][j]=0;
    }
    for(i=0;i<R;i++){
      scanf("%d%d%d%s",&ID,&PID,&Ti,S);
      if(S[0]=='W')PP[ID][PID]++;
      else if(S[0]=='C'){
        team[ID].TT++;
	team[ID].Time+=(PP[ID][PID]*1200+Ti);
      }
    }
    for(i=1;i<T+1;i++){
      for(j=T;j>i;j--){
	if(team[j].TT>team[j-1].TT){
	  tmp=team[j];
	  team[j]=team[j-1];
	  team[j-1]=tmp;
	}
	else if(team[j].TT==team[j-1].TT && team[j].Time<team[j-1].Time){
	  tmp=team[j];
	  team[j]=team[j-1];
	  team[j-1]=tmp;
	}
      }
    }
    for(i=1;i<T+1;i++){
      printf("%d %d %d\n",team[i].TID,team[i].TT,team[i].Time);
    }
  }
  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 && p==0 && r==0)return 0;
    team T[t];
    memset(T,0,sizeof(T));
    for(int i=0;i<t;i++)T[i].id=i+1;

    int tid,tm,pid;
    string mes;
    for(int i=0;i<r;i++){
      cin>>tid>>pid>>tm>>mes;
      tid--;pid--;
      if(mes=="CORRECT" && T[tid].p[pid]>0){
	T[tid].ans++;
	T[tid].pena+=T[tid].p[pid]*1200 + tm;
	T[tid].p[pid]=-1;
      }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<cstring>
#include<algorithm>

using namespace std;

#define rep(i, n) for(int i = 0; i < int(n); ++i)

int wa[100][100];
int pe[100];
int ac[100];
int team[100];

int main() {
  int t, p, r;
  for (;;) {
    cin >> t >> p >> r;
    if (t == 0 && p == 0 && r == 0) break;
    memset(wa, 0, sizeof(wa));
    memset(pe, 0, sizeof(pe));
    memset(ac, 0, sizeof(ac));
    int tid, pid, time;
    string message;
    rep (i, r) {
      cin >> tid >> pid >> time >> message;
      --tid; --pid;
      if (message == "WRONG") ++wa[tid][pid]; 
      else {
	++ac[tid];
	pe[tid] += time + wa[tid][pid] * 1200;
      }
    }
    rep (i, t) team[i] = i;
    rep (i, t) for (int j = i + 1; j < t; ++j) {
      if (ac[team[i]] < ac[team[j]] || (ac[team[i]] == ac[team[j]] && pe[team[i]] > pe[team[j]]) || (ac[team[i]] == ac[team[j]] && pe[team[i]] == pe[team[j]] && team[i] > team[j])) swap(team[i], team[j]);
    }
    rep (i, t) cout << team[i]+1 << " " << ac[team[i]] << " " << pe[team[i]] << endl;
  }
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define X first
#define Y second

using namespace std;
typedef pair<int,int> pii;

int main(){
	int T, R, P;
	while(cin >> T >> P >> R, T|R|P){
		pii sc[100] = {};
		int pe[100][100] = {};
		rep(i,R){
			int tid, pid, time;
			string m;
			cin >> tid >> pid >> time >> m;
			if( m == "CORRECT" ){
				sc[tid].X--;
				sc[tid].Y += pe[tid][pid] + time;
			}else{
				pe[tid][pid] += 1200;
			}
		}
		vector<pair<pii,int> > v;
		rep(i,T) v.emplace_back( sc[i+1], i+1 );
		sort( v.begin(), v.end() );
		for(auto t: v){
			cout << t.Y << " ";
			cout << -t.X.X << " ";
			cout << t.X.Y << " ";
			cout << endl;
		}
	}
	return 0;
}

C++: #include<iostream>
#include<tuple>
#include<queue>

using namespace std;

signed main(){

   while(1){
      int T, P, R;
      cin>> T>> P>> R;
      if(!(T||P||R)) break;

      int hoge[T][P];
      fill((int*)hoge, (int*)hoge+T*P, 0);
      for(int i=0; i<R; i++){
         int team, prob, time;
         string s;
         cin>> team>> prob>> time>> s;
         team--; prob--;
         if(s=="CORRECT"){
            hoge[team][prob]=1200*max(0-hoge[team][prob], 0)+time;
         }else{
            hoge[team][prob]--;
         }
      }
      priority_queue<tuple<int, int, int>> Q;
      for(int i=0; i<T; i++){
         int ac=0, pena=0;
         for(int j=0; j<P; j++){
            ac+=(hoge[i][j]>0);
            pena+=max(hoge[i][j], 0);
         }
         Q.push(make_tuple(ac, -pena, -i));
      }



      for(int i=0; i<T; i++){
         int ac, pena, team;
         tie(ac, pena, team)=Q.top(); Q.pop();
         cout<< -team+1<< " "<< ac<< " "<< -pena<< endl;
      }

   }

   return 0;
}

C++: #include <iostream>
#include <algorithm>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
#define INF 1000000000
using namespace std;
typedef pair<int, int> pii;
typedef pair<pii, int> score;

int T, P, R;
int w[50][10];
score s[50];

int main(void) {
  while(cin >> T >> P >> R, T || P || R) {
    REP(i, 0, T) {
      REP(j, 0, P) w[i][j] = 0;
      s[i] = score(pii(0, 0), -i);
    }

    REP(i, 0, R) {
      int tid, pid, time;
      string message;
      cin >> tid >> pid >> time >> message;
      tid--;
      pid--;
      if(message == "CORRECT") {
        s[tid].first.first++;
        s[tid].first.second -= w[tid][pid] * 1200 + time;
      } else {
        w[tid][pid]++;
      }
    }

    sort(s, s + T);
    reverse(s, s + T);

    REP(i, 0, T) cout << (-s[i].second + 1) << " " << s[i].first.first << " " << -s[i].first.second << endl;
  }
}