結果

問題 No.345 最小チワワ問題
ユーザー mizunomi32mizunomi32
提出日時 2016-02-28 22:26:36
言語 Java21
(openjdk 21)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,105 bytes
コンパイル時間 3,739 ms
コンパイル使用メモリ 78,040 KB
実行使用メモリ 41,848 KB
最終ジャッジ日時 2024-04-16 17:40:55
合計ジャッジ時間 8,665 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,456 KB
testcase_01 AC 131 ms
41,848 KB
testcase_02 AC 130 ms
41,520 KB
testcase_03 AC 128 ms
41,524 KB
testcase_04 AC 130 ms
41,512 KB
testcase_05 AC 131 ms
41,376 KB
testcase_06 AC 128 ms
41,320 KB
testcase_07 AC 133 ms
41,312 KB
testcase_08 AC 131 ms
41,408 KB
testcase_09 AC 129 ms
41,564 KB
testcase_10 AC 134 ms
41,348 KB
testcase_11 AC 129 ms
41,588 KB
testcase_12 AC 128 ms
41,420 KB
testcase_13 AC 126 ms
41,364 KB
testcase_14 AC 129 ms
41,396 KB
testcase_15 AC 128 ms
41,656 KB
testcase_16 AC 129 ms
41,200 KB
testcase_17 WA -
testcase_18 AC 128 ms
41,232 KB
testcase_19 AC 127 ms
41,668 KB
testcase_20 AC 128 ms
41,316 KB
testcase_21 AC 130 ms
41,336 KB
testcase_22 AC 127 ms
41,156 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 126 ms
41,636 KB
testcase_29 AC 127 ms
41,404 KB
testcase_30 AC 127 ms
41,168 KB
testcase_31 AC 127 ms
41,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char[] chars = s.toCharArray();
        int charlonger = s.length();
        int i=0;
        int flag =0;
        int flag2=0;
        int a=0,b=-1,c=0;



        for(;i<charlonger;i++){
            if(chars[i] == 'c'){
                flag = 1;
                a=i;
            }else if(flag == 1 && chars[i] == 'w'){
                  flag = 2;

            }else if(flag == 2 && chars[i] == 'w' ){

                flag=0;
                if(i-a+1 <b || b==-1){
                    b= i-a+1;
                }

            }
            if(chars[i] =='c'&& flag2==0){
                flag2 = 1;
                c=i;
            }else if(flag2 == 1 && chars[i] == 'w'){
                flag2 = 2;

            }else if(flag2 == 2 && chars[i] == 'w' ){

                flag2=0;
                if(i-c+1 <b || b==-1){
                    b= i-c+1;
                }

            }
        }
            System.out.println(b);
    }
}
0