結果

問題 No.345 最小チワワ問題
ユーザー YOSHIYOSHI
提出日時 2021-03-10 21:51:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 2,820 ms
コンパイル使用メモリ 74,196 KB
実行使用メモリ 52,468 KB
最終ジャッジ日時 2024-04-20 16:18:08
合計ジャッジ時間 5,298 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
37,068 KB
testcase_01 AC 49 ms
36,936 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 49 ms
37,028 KB
testcase_11 WA -
testcase_12 AC 49 ms
36,820 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 49 ms
36,680 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 49 ms
37,028 KB
testcase_20 AC 48 ms
36,664 KB
testcase_21 AC 47 ms
36,832 KB
testcase_22 AC 47 ms
36,972 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 49 ms
37,032 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No00000345_Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args) throws IOException {
		String s = br.readLine();
		int cnt = 0;
		int step = 0;
		for(int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if(step != 0) cnt++;
			if(c == 'c') {
				if(step == 0) {
					step++;
					cnt++;
				} else {
					cnt = -1;
					break;
				}
			} else if(c == 'w') {
				if(step == 1) {
					step++;
				} else if(step == 2) {
					break;
				}
			}
		}
		System.out.println(cnt);
	}
}
0