結果

問題 No.345 最小チワワ問題
ユーザー maru
提出日時 2016-03-24 01:52:20
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 622 bytes
コンパイル時間 3,641 ms
コンパイル使用メモリ 76,156 KB
実行使用メモリ 42,752 KB
最終ジャッジ日時 2024-10-01 21:42:39
合計ジャッジ時間 9,080 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class yukicoder_345 {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		String str1 = stdIn.next();
		
		int mojisu = -1;
		
		int c = str1.indexOf("c");
		
		if (c != -1) {
			String str2 = str1.substring(c + 1);
			int w1 = str2.indexOf("w");
			
			if (w1 != -1) {
				String str3 = str2.substring(w1 + 1);
				
				int w2 = str3.indexOf("w");
				
				if(w2 != -1) {
					String moji = str1.substring(c, c + 1) + str2.substring(0, w1 + 1) + str3.substring(0, w2 + 1);
					mojisu = moji.length();				}
			}
		}
		System.out.println(mojisu);
	}
}
0