package PAT;
import java.util.Objects;
import java.util.Scanner;
public class B1018 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
int winCa = 0;
int winJa = 0;
int winBa = 0;
int winCb = 0;
int winJb = 0;
int winBb = 0;
int draw = 0;
for (int i = 0; i < 10; i++) {
String a = scanner.next();
String b = scanner.next();
if (Objects.equals(a, b)) draw++;
else if (Objects.equals(a, "C")) {
if (Objects.equals(b, "J")) winCa++;
if (Objects.equals(b, "B")) winBb++;
} else if (Objects.equals(a, "J")) {
if (Objects.equals(b, "B")) winJa++;
if (Objects.equals(b, "C")) winCb++;
} else if (Objects.equals(a, "B")) {
if (Objects.equals(b, "C")) winBa++;
if (Objects.equals(b, "J")) winJb++;
}
}
System.out.println(winBa + winCa + winJa + " " + draw + " " + (winBb + winCb + winJb));
System.out.println(winBb + winCb + winJb + " " + draw + " " + (winBa + winCa + winJa));
if (winJa > winCa && winJa > winBa) {
System.out.print("J");
} else if (winCa > winBa) {
System.out.print("C");
} else {
System.out.print("B");
}
System.out.print(" ");
if (winJb > winCb && winJb > winBb) {
System.out.print("J");
} else if (winCb > winBb) {
System.out.print("C");
} else {
System.out.print("B");
}
}
}
上述代码能完美运行PAT给的测试用例,我自己改了几组也能完美实现。
但一到提交的时候就全部答案错误(不是运行超时)。
我自己自查之后依然找不到问题。
希望能解决问题。