結果

問題 No.342 一番ワロタww
ユーザー uwiuwi
提出日時 2016-02-12 23:34:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 1,578 bytes
コンパイル時間 4,424 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 41,544 KB
最終ジャッジ日時 2024-04-23 13:16:14
合計ジャッジ時間 7,157 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,108 KB
testcase_01 AC 122 ms
41,364 KB
testcase_02 AC 121 ms
41,408 KB
testcase_03 AC 125 ms
41,056 KB
testcase_04 AC 122 ms
40,940 KB
testcase_05 AC 122 ms
41,124 KB
testcase_06 AC 125 ms
41,544 KB
testcase_07 AC 121 ms
40,832 KB
testcase_08 AC 127 ms
41,260 KB
testcase_09 AC 126 ms
41,260 KB
testcase_10 AC 127 ms
41,424 KB
testcase_11 AC 108 ms
40,164 KB
testcase_12 AC 119 ms
41,120 KB
testcase_13 AC 121 ms
40,784 KB
testcase_14 AC 121 ms
41,140 KB
testcase_15 AC 125 ms
40,952 KB
testcase_16 AC 123 ms
41,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package contest;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class B {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";
	
	static void solve()
	{
		char[] S = in.nextLine().toCharArray();
		char w = 'w';
		char[] T = null;
		for(int i = 0;i < S.length;i++){
			if(S[i] != w){
				T = Arrays.copyOfRange(S, i, S.length);
				break;
			}
		}
		if(T == null){
			out.println();
			return;
		}
		S = T;
		
		int max = 0;
		int ws = 0;
		List<Integer> ends = new ArrayList<>();
		for(int i = 0;i < S.length;i++){
			char c = S[i];
			if(c == w){
				ws++;
				if(ws == max){
					ends.add(i);
				}else if(ws > max){
					max = ws;
					ends.clear();
					ends.add(i);
				}
			}else{
				ws = 0;
			}
		}
		if(ends.isEmpty()){
			out.println();
		}else{
			for(int end : ends){
				if(end-max == -1)continue;
				int start = end-max;
				while(start >= 0 && S[start] != w)start--;
				for(int i = start+1;i <= end-max;i++){
					out.print(S[i]);
				}
				out.println();
			}
		}
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
0