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 <algorithm>
#include <vector>

using namespace std;

int main()
{
  int n, m, s, t;
  bool a[101][101];
  int b[101];
  vector<int> vec;

  while(cin >> n && n){
    fill(&a[0][0], &a[101][0], false);
    fill(b, b+101, 0);

    for(int i = 1; i <= n; ++i){
      cin >> m;
      for(int j = 0; j < m; ++j){
	cin >> t;
	a[i][t] = true;
      }
    }
    cin >> t;
    for(int i = 0; i < t; ++i)
      cin >> b[i];

    for(int i = 1; i <= n; ++i){
      s = 0;
      for(int j = 0; j < t; ++j)
	if(a[i][b[j]]) ++s;
      if(t == s) vec.push_back(i);
    }

    if(vec.size() == 1) cout << vec[0] << endl;
    else cout << "-1" << endl;

    vec.clear();
  }

  return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int t, p, r;
    while(cin >> t >> p >> r, t+p+r){
        bool correct[t][r];
        int submit[t][r];
        int penalty[t][r];
        rep(i, t)rep(j, r){penalty[i][j] = 0; submit[i][j] = 0; correct[i][j] = false;}
        rep(k, r){
            int team, problem, time;
            string message;

            cin >> team >> problem >> time >> message;
            team--; problem--;

            if(message == "CORRECT"){
                correct[team][problem] = true;
                penalty[team][problem] += submit[team][problem]*1200+time;
            }
            submit[team][problem]++;
        }

        vector<pair<int, pair<int, int> > > v(t);
        rep(i, t){
            int ca = 0, pn = 0;
            rep(j, p){
                if(correct[i][j])ca++;
                pn += penalty[i][j];
            }
            v[i] = mp(ca, mp(inf-pn, 100-i));
        }
        sort(all(v));

        for(int i=t-1; 0 <= i; i--){
            cout << 100- v[i].second.second+1 << " " << v[i].first << " " << inf-v[i].second.first << endl;
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

const int MAX_P=11;

struct team{
    int solve,penalty,num;
    vector<int> wrong;
    team(int solve,int penalty,int num):solve(solve),penalty(penalty),num(num),wrong(MAX_P,0){}
    bool operator<(const team &rhs){
        if (solve!=rhs.solve) return solve>rhs.solve;
        if (penalty!=rhs.penalty) return penalty<rhs.penalty;
        return num<rhs.num;
    }
};

int T,P,R,t,p,ti; string r;
vector<team> teams;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> T >> P >> R,T){
        teams.clear();
        for (int i=0;i<T;++i) teams.emplace_back(0,0,i+1);
        for (int i=0;i<R;++i){
            cin >> t >> p >> ti >> r; --t,--p;
            if (r=="WRONG") ++teams[t].wrong[p];
            else {
                ++teams[t].solve;
                teams[t].penalty+=ti+teams[t].wrong[p]*1200;
            }
        }
        sort(teams.begin(),teams.end());
        for (int i=0;i<T;++i){
            team te=teams[i];
            cout << te.num << ' ' << te.solve << ' ' << te.penalty << '\n';
        }
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
typedef pair<int, pair<int, int> > tpair;

struct hoge{
  bool operator()(const tpair& a, const tpair& b){
    if(a.second.first != b.second.first) return a.second.first > b.second.first;
    else if(a.second.second != b.second.second) return a.second.second < b.second.second;
    else return a.first < b.first;
  }
}; 

int main(){
  int T, P, R;
  while(scanf("%d%d%d", &T, &P, &R) && (T||P||R)){
    //    vector<pair<int, pair<int, int> > > t(T); // team ac p
    vector<tpair> t(T);
    int fail[11][11] = {};
    int tid, pid, time;
    char message[16];
    rep(i, T) t[i].first = i+1;     
    rep(i, R){
      scanf("%d%d%d%s", &tid, &pid, &time, message); tid--; pid--;
      if(message[0] == 'C'){
	if(fail[tid][pid] != -1){
	//  t[tid].second.first++;
	  t[tid].second.second += fail[tid][pid] * 1200 + time;
	  fail[tid][pid] = -1; 
	}
      }else if(message[0] == 'W'){
	if(fail[tid][pid] != -1)
	  fail[tid][pid]++;
      }
    } 
    sort(t.begin(), t.end(), hoge());
    rep(i, T) printf("%d %d %d\n", t[i].first, t[i].second.first, t[i].second.second);
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define MP(a, b) make_pair(a, b)
#define F first
#define S second

int main() {
	int T, P, R; // team, problem, log
	while (cin >> T >> P >> R, T || P || R) {
		pair<bool, int> val[51][11]; // <correct, penalty>=[team, problem]
		REP(i, 0, T) REP(j, 0, P) val[i][j] = MP(false, 0);

		REP(i, 0, R) {
			int team, prob, time;
			string mes;
			cin >> team >> prob >> time >> mes;
			team--;
			prob--;

			if (mes == "WRONG") {
				val[team][prob].S += 1200;
			}
			else {
				val[team][prob].F = true;
				val[team][prob].S += time;
			}
		}

		pair<int, pair<int, int>> ans[51]; // <#correct, <penalty, team>>
		REP(i, 0, T) ans[i] = MP(0, MP(0, i + 1));
		REP(i, 0, T) {
			REP(j, 0, P) {
				if (val[i][j].F) {
					ans[i].F--;
					ans[i].S.F += val[i][j].S;
				}
			}
		}

		sort(ans, ans + T);
		REP(i, 0, T) cout << ans[i].S.S << " " << -ans[i].F << " " << ans[i].S.F << endl;
	}
	return 0;
}