結果
問題 |
No.197 手品
|
ユーザー |
![]() |
提出日時 | 2015-04-28 23:43:49 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,579 bytes |
コンパイル時間 | 2,151 ms |
コンパイル使用メモリ | 77,592 KB |
実行使用メモリ | 54,192 KB |
最終ジャッジ日時 | 2024-06-27 07:17:50 |
合計ジャッジ時間 | 9,155 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 38 WA * 5 |
ソースコード
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; } else if (before.equals("122") || before.equals("221")) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } if (before.equals("122") || before.equals("221")) { if (after.equals("212")) { if (N > 0) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } else { if (N > 1) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } } else { if (N > 0) { System.out.println("FAILURE"); return; } System.out.println("SUCCESS"); return; } } }