結果

問題 No.342 一番ワロタww
ユーザー 37zigen37zigen
提出日時 2016-03-22 15:17:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,159 bytes
コンパイル時間 3,218 ms
コンパイル使用メモリ 87,416 KB
実行使用メモリ 58,976 KB
最終ジャッジ日時 2024-04-08 21:53:29
合計ジャッジ時間 6,313 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 169 ms
58,848 KB
testcase_01 AC 167 ms
58,860 KB
testcase_02 WA -
testcase_03 AC 166 ms
58,840 KB
testcase_04 AC 179 ms
58,844 KB
testcase_05 WA -
testcase_06 AC 166 ms
58,852 KB
testcase_07 WA -
testcase_08 AC 185 ms
58,872 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 179 ms
58,892 KB
testcase_12 WA -
testcase_13 AC 184 ms
58,880 KB
testcase_14 AC 180 ms
58,856 KB
testcase_15 AC 148 ms
57,720 KB
testcase_16 AC 175 ms
58,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder342;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
	static class Tuple implements Comparable<Tuple>{
		String str;
		int count;
		Tuple(String str,int count){
			this.str=str;
			this.count=count;
		}
		public int compareTo(Tuple o){
			int a=Integer.compare(o.count, count);
			if(a==0)return 1;
			return a;
		}
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		PriorityQueue<Tuple> queue=new PriorityQueue(100);
		String str2="";
		int count=0;
		for(int i=0;i<str.length();i++){
			if(str.charAt(i)=='w'&&i==str.length()-1){
				count++;
				queue.add(new Tuple(str2,count));
			}else if(str.charAt(i)!='w'){
				if(i>=1){
					if(str.charAt(i-1)=='w'){
						if(!str2.equals("")){
							queue.add(new Tuple(str2,count));
						}
						str2="";
						count=0;
					}
				}
				str2+=str.charAt(i);
			}else if(str.charAt(i)=='w'){
				count++;
			}
		}
		if(queue.isEmpty()){
			System.out.println();
		}
		while(!queue.isEmpty()){
			Tuple t=queue.poll();
			System.out.println(t.str);
		}
//		System.err.println("End");
		sc.close();
	}
}
0