結果
問題 |
No.197 手品
|
ユーザー |
![]() |
提出日時 | 2015-04-28 23:35:38 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,495 bytes |
コンパイル時間 | 2,082 ms |
コンパイル使用メモリ | 77,648 KB |
実行使用メモリ | 56,296 KB |
最終ジャッジ日時 | 2024-06-27 07:15:06 |
合計ジャッジ時間 | 9,251 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 WA * 19 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String before = sc.next(); int N = sc.nextInt(); String after = sc.next(); sc.close(); int bCoins = 0; int aCoins = 0; for (int i = 0; i < 3; i++) { if (before.charAt(i) == 'o') { bCoins++; } if (after.charAt(i) == 'o') { aCoins++; } } if (aCoins != bCoins) { System.out.println("SUCCESS"); return; } if (aCoins == 0 || aCoins == 3) { System.out.println("FAILURE"); return; } if (aCoins == 1) { before = before.replaceAll("o", "1").replaceAll("x", "2"); after = after.replaceAll("o", "1").replaceAll("x", "2"); } else { before = before.replaceAll("o", "2").replaceAll("x", "1"); after = after.replaceAll("o", "2").replaceAll("x", "1"); } if (before.equals(after)) { if (N % 2 == 0) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } if (before.equals("122") || before.equals("221")) { if (after.equals("212")) { if (N % 2 == 1) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } else { if (N % 2 == 1 || N < 2) { System.out.println("SUCCESS"); return; } System.out.println("FAILURE"); return; } } else { if (N % 2 == 0) { System.out.println("SUCCESS"); return; } System.out.println("FAILURE"); return; } } }