結果
問題 | No.342 一番ワロタww |
ユーザー |
|
提出日時 | 2016-03-22 15:25:23 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 169 ms / 5,000 ms |
コード長 | 1,234 bytes |
コンパイル時間 | 2,410 ms |
コンパイル使用メモリ | 80,020 KB |
実行使用メモリ | 42,808 KB |
最終ジャッジ日時 | 2024-10-15 13:22:35 |
合計ジャッジ時間 | 6,102 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
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.nextLine(); 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(); } }