結果
問題 | No.197 手品 |
ユーザー | uafr_cs |
提出日時 | 2015-04-28 23:58:11 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 42 ms / 1,000 ms |
コード長 | 2,581 bytes |
コンパイル時間 | 2,061 ms |
コンパイル使用メモリ | 76,444 KB |
実行使用メモリ | 49,836 KB |
最終ジャッジ日時 | 2023-09-27 09:26:08 |
合計ジャッジ時間 | 5,435 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
49,356 KB |
testcase_01 | AC | 40 ms
49,308 KB |
testcase_02 | AC | 39 ms
49,388 KB |
testcase_03 | AC | 40 ms
49,528 KB |
testcase_04 | AC | 41 ms
49,308 KB |
testcase_05 | AC | 41 ms
49,404 KB |
testcase_06 | AC | 39 ms
49,312 KB |
testcase_07 | AC | 39 ms
49,468 KB |
testcase_08 | AC | 40 ms
49,364 KB |
testcase_09 | AC | 40 ms
49,464 KB |
testcase_10 | AC | 39 ms
49,828 KB |
testcase_11 | AC | 37 ms
49,288 KB |
testcase_12 | AC | 39 ms
49,640 KB |
testcase_13 | AC | 39 ms
49,256 KB |
testcase_14 | AC | 39 ms
49,332 KB |
testcase_15 | AC | 39 ms
49,468 KB |
testcase_16 | AC | 38 ms
49,604 KB |
testcase_17 | AC | 40 ms
49,740 KB |
testcase_18 | AC | 40 ms
49,332 KB |
testcase_19 | AC | 39 ms
49,384 KB |
testcase_20 | AC | 38 ms
49,252 KB |
testcase_21 | AC | 39 ms
49,280 KB |
testcase_22 | AC | 40 ms
49,520 KB |
testcase_23 | AC | 41 ms
49,312 KB |
testcase_24 | AC | 40 ms
49,388 KB |
testcase_25 | AC | 41 ms
49,324 KB |
testcase_26 | AC | 41 ms
49,548 KB |
testcase_27 | AC | 39 ms
49,280 KB |
testcase_28 | AC | 38 ms
49,348 KB |
testcase_29 | AC | 39 ms
49,288 KB |
testcase_30 | AC | 39 ms
49,500 KB |
testcase_31 | AC | 38 ms
49,580 KB |
testcase_32 | AC | 39 ms
49,368 KB |
testcase_33 | AC | 39 ms
49,504 KB |
testcase_34 | AC | 40 ms
49,408 KB |
testcase_35 | AC | 39 ms
49,216 KB |
testcase_36 | AC | 40 ms
49,836 KB |
testcase_37 | AC | 41 ms
49,308 KB |
testcase_38 | AC | 42 ms
49,832 KB |
testcase_39 | AC | 42 ms
49,288 KB |
testcase_40 | AC | 40 ms
49,260 KB |
testcase_41 | AC | 41 ms
49,304 KB |
testcase_42 | AC | 41 ms
49,404 KB |
testcase_43 | AC | 40 ms
49,284 KB |
testcase_44 | AC | 38 ms
49,360 KB |
testcase_45 | AC | 38 ms
49,464 KB |
testcase_46 | AC | 40 ms
49,380 KB |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final char[] S_before = sc.next().toCharArray(); final long N = sc.nextLong(); final char[] S_after = sc.next().toCharArray(); final int SIZE = 3; int before_circles = 0; for(char c : S_before){ if(c == 'o'){ before_circles++; } } int after_circles = 0; for(char c : S_after){ if(c == 'o'){ after_circles++; } } if(before_circles != after_circles){ System.out.println("SUCCESS"); }else if(before_circles == 3 || before_circles == 0){ System.out.println("FAILURE"); }else{ final char purpose = before_circles == 1 ? 'o' : 'x'; int before_pos = -1, after_pos = -1; for(int i = 0; i < SIZE; i++){ if(S_before[i] == purpose){ before_pos = i; } if(S_after[i] == purpose){ after_pos = i; } } final long diff = Math.abs(before_pos - after_pos); if(diff == 2 || diff == 1 || before_pos == 0 || before_pos == SIZE - 1 || N == 0){ System.out.println(diff <= N ? "FAILURE" : "SUCCESS"); }else{ System.out.println(2 <= N ? "FAILURE" : "SUCCESS"); } } } public static void trace(Object... args) { System.out.println(Arrays.deepToString(args)); } public static class Scanner { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public void close() throws IOException { br.close(); } } }