結果

問題 No.342 一番ワロタww
ユーザー かにかに
提出日時 2016-02-13 00:51:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 5,000 ms
コード長 1,802 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 86,472 KB
実行使用メモリ 42,772 KB
最終ジャッジ日時 2024-04-23 13:18:36
合計ジャッジ時間 5,825 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
42,476 KB
testcase_01 AC 166 ms
42,432 KB
testcase_02 AC 160 ms
42,504 KB
testcase_03 AC 157 ms
42,644 KB
testcase_04 AC 158 ms
42,424 KB
testcase_05 AC 158 ms
42,704 KB
testcase_06 AC 152 ms
41,880 KB
testcase_07 AC 163 ms
42,312 KB
testcase_08 AC 162 ms
42,392 KB
testcase_09 AC 163 ms
42,772 KB
testcase_10 AC 164 ms
42,536 KB
testcase_11 AC 163 ms
42,240 KB
testcase_12 AC 161 ms
42,500 KB
testcase_13 AC 156 ms
42,192 KB
testcase_14 AC 126 ms
41,232 KB
testcase_15 AC 130 ms
41,236 KB
testcase_16 AC 157 ms
42,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int wcnt = 0;
        for(int i = 0;i < s.length();i++){
        	if(s.charAt(i) == 'w')wcnt++;
        }
        if(wcnt == 0 || wcnt == s.length()){
        	System.out.println("");
        	return;
        }
        int l = 0;
        int maxi = 0;
        String tmp = "",maxs = new String();
        Queue<String> que = new ArrayDeque<String>();
        int i = 0;
        for(;i < s.length();){
            l = 0;
            while(i < s.length() && s.charAt(i) != 'w'){
                tmp = tmp + s.charAt(i);
                i++;
            }
            while(i < s.length() && s.charAt(i) == 'w'){
                l++;
                i++;
            }
            if(l > maxi && tmp != ""){
                maxi = l;
                while(!que.isEmpty()){
                    que.remove();
                }
                que.add(tmp);
                tmp = "";
            }else if(l == maxi && tmp != "" && l != 0){
                que.add(tmp);
                tmp = "";
            }else{
            	tmp = "";
            }
        }
        if(l > maxi && tmp != ""){
            maxi = l;
            while(!que.isEmpty()){
                que.remove();
            }
            que.add(tmp);
            tmp = "";
        }else if(l == maxi && tmp != ""){
            que.add(tmp);
            tmp = "";
        }
        if(que.size() == 0){
        	System.out.println("");
        }
        while(!que.isEmpty()){
            System.out.println(que.element());
            que.remove();
        }
    }
}
	
0