結果

問題 No.342 一番ワロタww
ユーザー 37zigen37zigen
提出日時 2016-03-22 15:21:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,230 bytes
コンパイル時間 2,420 ms
コンパイル使用メモリ 79,836 KB
実行使用メモリ 59,148 KB
最終ジャッジ日時 2024-04-08 21:54:39
合計ジャッジ時間 6,063 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 172 ms
59,148 KB
testcase_01 AC 166 ms
58,976 KB
testcase_02 AC 172 ms
58,992 KB
testcase_03 AC 169 ms
58,864 KB
testcase_04 AC 165 ms
58,876 KB
testcase_05 AC 164 ms
58,896 KB
testcase_06 AC 167 ms
58,872 KB
testcase_07 WA -
testcase_08 AC 167 ms
58,868 KB
testcase_09 AC 165 ms
58,880 KB
testcase_10 AC 161 ms
58,864 KB
testcase_11 AC 165 ms
58,876 KB
testcase_12 AC 165 ms
58,884 KB
testcase_13 AC 165 ms
58,880 KB
testcase_14 AC 170 ms
59,128 KB
testcase_15 AC 132 ms
57,860 KB
testcase_16 AC 166 ms
58,864 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();
			System.exit(0);
		}
		int a=queue.peek().count;
		while(!queue.isEmpty()){
			Tuple t=queue.poll();
			if(a!=t.count)break;
			System.out.println(t.str);
		}
//		System.err.println("End");
		sc.close();
	}
}
0