import java.io.IOException;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.util.Scanner;
class Main
{
public static final boolean DEBUG = false;
public static int[][] s1, s2;
public static int[] w;
public static boolean test(int c, int m)
{
for (int i = 0; i < 3; i++) {
int s = 0, t = 0;
for (int j = 0; j < s1[i].length; j++) {
if (s1[i][j] == c) s += m;
}
for (int j = 0; j < s2[i].length; j++) {
if (s2[i][j] == c) t += m;
}
if (s < t && w[i] != -1) return false;
if (s > t && w[i] != 1) return false;
if (s == t && w[i] != 0) return false;
}
return true;
}
public static void main(String[] args) throws IOException
{
Scanner cin;
int n;
String s;
if (DEBUG) {
cin = new Scanner(new FileReader("d:\\OJ\\uva_in.txt"));
} else {
cin = new Scanner(new InputStreamReader(System.in));
}
s1 = new int[3][];
s2 = new int[3][];
w = new int[3];
n = cin.nextInt();
while (n-- > 0) {
for (int i = 0; i < 3; i++) {
s = cin.next();
s1[i] = new int[s.length()];
for (int j = 0; j < s.length(); j++) {
s1[i][j] = s.charAt(j) - 'A';
}
s = cin.next();
s2[i] = new int[s.length()];
for (int j = 0; j < s.length(); j++) {
s2[i][j] = s.charAt(j) - 'A';
}
s = cin.next();
if (s.charAt(0) == 'e') w[i] = 0;
else if (s.charAt(0) == 'u') w[i] = 1;
else if (s.charAt(0) == 'd') w[i] = -1;
}
for (int i = 0; i < 12; i++) {
if (test(i, -1)) {
System.out.println((char)('A' + i) + " is the counterfeit coin and it is light.");
break;
}
if (test(i, 1)) {
System.out.println((char)('A' + i) + " is the counterfeit coin and it is heavy.");
break;
}
}
}
}
}
题目1150:Counterfeit Dollar
最新推荐文章于 2020-03-07 22:12:55 发布