結果
問題 | No.197 手品 |
ユーザー | uafr_cs |
提出日時 | 2015-04-28 23:43:09 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,468 bytes |
コンパイル時間 | 2,180 ms |
コンパイル使用メモリ | 79,932 KB |
実行使用メモリ | 52,488 KB |
最終ジャッジ日時 | 2024-06-27 07:17:21 |
合計ジャッジ時間 | 5,765 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 50 ms
37,208 KB |
testcase_01 | AC | 51 ms
36,980 KB |
testcase_02 | AC | 51 ms
36,952 KB |
testcase_03 | AC | 51 ms
37,168 KB |
testcase_04 | AC | 50 ms
37,200 KB |
testcase_05 | AC | 51 ms
37,132 KB |
testcase_06 | AC | 51 ms
36,700 KB |
testcase_07 | AC | 50 ms
37,212 KB |
testcase_08 | AC | 51 ms
37,344 KB |
testcase_09 | AC | 51 ms
36,920 KB |
testcase_10 | AC | 51 ms
37,008 KB |
testcase_11 | AC | 52 ms
37,048 KB |
testcase_12 | WA | - |
testcase_13 | AC | 50 ms
37,324 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 49 ms
36,708 KB |
testcase_24 | AC | 50 ms
36,696 KB |
testcase_25 | AC | 50 ms
37,044 KB |
testcase_26 | AC | 51 ms
37,264 KB |
testcase_27 | WA | - |
testcase_28 | AC | 51 ms
36,980 KB |
testcase_29 | WA | - |
testcase_30 | AC | 50 ms
37,328 KB |
testcase_31 | AC | 50 ms
36,828 KB |
testcase_32 | AC | 52 ms
37,132 KB |
testcase_33 | WA | - |
testcase_34 | AC | 50 ms
37,104 KB |
testcase_35 | AC | 50 ms
37,216 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | AC | 49 ms
36,704 KB |
testcase_39 | WA | - |
testcase_40 | AC | 51 ms
37,076 KB |
testcase_41 | WA | - |
testcase_42 | AC | 50 ms
36,924 KB |
testcase_43 | AC | 51 ms
36,824 KB |
testcase_44 | WA | - |
testcase_45 | AC | 52 ms
36,884 KB |
testcase_46 | WA | - |
ソースコード
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); //trace(diff); System.out.println(diff <= N && (N - diff) % 2 == 0 ? "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(); } } }