結果

問題 No.197 手品
ユーザー chiho_miyako
提出日時 2015-04-28 23:50:32
言語 Java
(openjdk 23)
結果
AC  
実行時間 132 ms / 1,000 ms
コード長 2,600 bytes
コンパイル時間 2,309 ms
コンパイル使用メモリ 78,344 KB
実行使用メモリ 41,624 KB
最終ジャッジ日時 2024-07-20 03:34:17
合計ジャッジ時間 8,614 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        String st = koko.next();
        long n = koko.nextLong();
        String end = koko.next();
        int stm = 0;
        int stb = 0;
        int enm = 0;
        int enb = 0;
        for(int i=0; i<3; i++){
        	if(st.charAt(i)=='o'){
        		stm++;
        	}else{
        		stb++;
        	}
        	if(end.charAt(i)=='o'){
        		enm++;
        	}else{
        		enb++;
        	}
        }
        if(stb==enb&&stm==enm){
        	if(st.equals("oox")){
        	    if(n==0&&!end.equals("oox")){
        		    System.out.println("SUCCESS");
        	    }else if(n==1&&end.equals("xoo")){
        		    System.out.println("SUCCESS");
        	    }else{
        		    System.out.println("FAILURE");
        	    }
            }else if(st.equals("xoo")){
        	    if(n==0&&!end.equals("xoo")){
        		    System.out.println("SUCCESS");
        	    }else if(n==1&&end.equals("oox")){
            		System.out.println("SUCCESS");
            	}else{
        	    	System.out.println("FAILURE");
        	    }
            }else if(st.equals("oxo")){
            	if(n==0&&!end.equals("oxo")){
            		System.out.println("SUCCESS");
            	}else if(n==1&&end.equals("oxo")){
        	    	System.out.println("SUCCESS");
        	    }else{
        	    	System.out.println("FAILURE");
        	    }
            }else if(st.equals("xxo")){
        	    if(n==0&&!end.equals("xxo")){
        		    System.out.println("SUCCESS");
        	    }else if(n==1&&end.equals("oxx")){
        		    System.out.println("SUCCESS");
        	    }else{
        		    System.out.println("FAILURE");
        	    }
            }else if(st.equals("oxx")){
        	    if(n==0&&!end.equals("oxx")){
        		    System.out.println("SUCCESS");
        	    }else if(n==1&&end.equals("xxo")){
            		System.out.println("SUCCESS");
            	}else{
        	    	System.out.println("FAILURE");
        	    }
            }else if(st.equals("xox")){
            	if(n==0&&!end.equals("xox")){
            		System.out.println("SUCCESS");
            	}else if(n==1&&end.equals("xox")){
        	    	System.out.println("SUCCESS");
        	    }else{
        	    	System.out.println("FAILURE");
        	    }
            }else if(st.equals("xxx")||st.equals("ooo")){
            	System.out.println("FAILURE");
            }
        }else{
        	System.out.println("SUCCESS");
        }
        
        
    }
}
0