1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| import java.util.Scanner;
public class Main { static String[] choices = new String[]{"Rock", "Scissor", "Paper"}; public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); String s1 = scanner.nextLine(); String s2 = scanner.nextLine(); String[] alice = s1.split(" "), bob = s2.split(" "); int ans1 = 0, ans2 = 0; for (int i = 0; i < n; i++) { int score = isWin(alice[i], bob[i]); if (score == 0) continue; if (score > 0) ans1++; else ans2++; } System.out.println(ans1 + " " + ans2); }
public static int isWin(String s1, String s2) { if (s1.equals(choices[0]) && s2.equals(choices[1])) return 1; if (s1.equals(choices[1]) && s2.equals(choices[2])) return 1; if (s1.equals(choices[2]) && s2.equals(choices[0])) return 1; if (s1.equals(s2)) return 0; return -1; } }
|