import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int cases = Integer.parseInt(br.readLine());
br.readLine();
for (int i = 0; i < cases; i++) {
if (i > 0) {
sb.append("\n");
}
Team[] teams = new Team[101];
for (int j = 0; j < teams.length; j++) {
teams[j] = new Team(j);
}
int[][] teamSolv = new int[101][10];
boolean[][] teamAcc = new boolean[101][10];
String m = "";
boolean[] sub = new boolean[101];
while ((m = br.readLine()) != null) {
if (m.trim().equals("")) {
break;
}
String[] str = m.split(" ");
int teamNo = Integer.parseInt(str[0]);
sub[teamNo] = true;
int problem = Integer.parseInt(str[1]);
int penalty = Integer.parseInt(str[2]);
String stat = str[3];
if (!teamAcc[teamNo][problem]) {
if (stat.equals("C")) {
int pentAcc = teamSolv[teamNo][problem] * 20 + penalty;
teamAcc[teamNo][problem] = true;
teams[teamNo].addsolved();
teams[teamNo].addPenalty(pentAcc);
} else if (stat.equals("I")) {
teamSolv[teamNo][problem]++;
}
}
}
Arrays.sort(teams);
for (int j = 0; j < teams.length; j++) {
int num = teams[j].getTeamN();
if (sub[num]) {
sb.append(teams[j].getTeamN()).append(" ").append(teams[j].getSolved()).append(" ").append(teams[j].getPenalty());
sb.append("\n");
}
}
}
System.out.print(sb);
}
}
class Team implements Comparable<Team> {
private int teamN, solved, penalty;
public Team(int team) {
this.solved = 0;
this.penalty = 0;
this.teamN = team;
}
public int getPenalty() {
return penalty;
}
public void setPenalty(int penalty) {
this.penalty = penalty;
}
public void addPenalty(int penalty) {
this.penalty += penalty;
}
public void addsolved() {
this.solved++;
}
public int getSolved() {
return solved;
}
public void setSolved(int solved) {
this.solved = solved;
}
public int getTeamN() {
return teamN;
}
public void setTeamN(int teamN) {
this.teamN = teamN;
}
@Override
public int compareTo(Team x) {
if (this.solved > x.getSolved()) {
return -1;
} else if (this.solved < x.getSolved()) {
return 1;
} else {
if (this.penalty > x.getPenalty()) {
return -1;
} else if (this.penalty < x.getPenalty()) {
return 1;
} else {
if (this.teamN > x.getTeamN()) {
return 1;
} else {
return -1;
}
}
}
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
int cases = Integer.parseInt(br.readLine());
br.readLine();
for (int i = 0; i < cases; i++) {
if (i > 0) {
sb.append("\n");
}
Team[] teams = new Team[101];
for (int j = 0; j < teams.length; j++) {
teams[j] = new Team(j);
}
int[][] teamSolv = new int[101][10];
boolean[][] teamAcc = new boolean[101][10];
String m = "";
boolean[] sub = new boolean[101];
while ((m = br.readLine()) != null) {
if (m.trim().equals("")) {
break;
}
String[] str = m.split(" ");
int teamNo = Integer.parseInt(str[0]);
sub[teamNo] = true;
int problem = Integer.parseInt(str[1]);
int penalty = Integer.parseInt(str[2]);
String stat = str[3];
if (!teamAcc[teamNo][problem]) {
if (stat.equals("C")) {
int pentAcc = teamSolv[teamNo][problem] * 20 + penalty;
teamAcc[teamNo][problem] = true;
teams[teamNo].addsolved();
teams[teamNo].addPenalty(pentAcc);
} else if (stat.equals("I")) {
teamSolv[teamNo][problem]++;
}
}
}
Arrays.sort(teams);
for (int j = 0; j < teams.length; j++) {
int num = teams[j].getTeamN();
if (sub[num]) {
sb.append(teams[j].getTeamN()).append(" ").append(teams[j].getSolved()).append(" ").append(teams[j].getPenalty());
sb.append("\n");
}
}
}
System.out.print(sb);
}
}
class Team implements Comparable<Team> {
private int teamN, solved, penalty;
public Team(int team) {
this.solved = 0;
this.penalty = 0;
this.teamN = team;
}
public int getPenalty() {
return penalty;
}
public void setPenalty(int penalty) {
this.penalty = penalty;
}
public void addPenalty(int penalty) {
this.penalty += penalty;
}
public void addsolved() {
this.solved++;
}
public int getSolved() {
return solved;
}
public void setSolved(int solved) {
this.solved = solved;
}
public int getTeamN() {
return teamN;
}
public void setTeamN(int teamN) {
this.teamN = teamN;
}
@Override
public int compareTo(Team x) {
if (this.solved > x.getSolved()) {
return -1;
} else if (this.solved < x.getSolved()) {
return 1;
} else {
if (this.penalty > x.getPenalty()) {
return -1;
} else if (this.penalty < x.getPenalty()) {
return 1;
} else {
if (this.teamN > x.getTeamN()) {
return 1;
} else {
return -1;
}
}
}
}
}
No comments:
Post a Comment