結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
kenji_shioya
|
| 提出日時 | 2016-05-29 23:56:41 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,448 bytes |
| コンパイル時間 | 3,667 ms |
| コンパイル使用メモリ | 78,728 KB |
| 実行使用メモリ | 54,472 KB |
| 最終ジャッジ日時 | 2024-10-07 17:48:59 |
| 合計ジャッジ時間 | 5,987 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 WA * 1 |
ソースコード
import java.util.*;
public class Exercise33{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
char[] charArray = str.toCharArray();
ArrayList<ResultStr> strList = new ArrayList<ResultStr>();
boolean preW = false;
boolean getChar = false;
boolean empty = true;
int wCount = 0;
int maxW = 0;
for (int n = charArray.length - 1; n >= 0; n--){
// wは全角注意
if (charArray[n] == 'w'){
if (preW){
wCount++;
}else{
preW = true;
wCount++;
}
if (getChar){
getChar = false;
}
// w以外の文字の時
}else{
// 候補1文字目
if(preW){
// Wcountをmaxと比較
maxW = Math.max(wCount, maxW);
if (wCount == maxW){
getChar = true;
// すでに候補がなければ
if (strList.isEmpty()){
ResultStr newStr = new ResultStr(wCount);
strList.add(0, newStr);
// あれば
}else{
ResultStr resultStr = strList.get(0);
if (wCount > resultStr.numOfW){
strList.clear();
ResultStr newStr = new ResultStr(wCount);
strList.add(0, newStr);
}else if(wCount == resultStr.numOfW){
ResultStr newStr = new ResultStr(wCount);
strList.add(0, newStr);
}
}
}
preW = false;
wCount = 0;
}
// 候補1文字目終わり
// 2文字目以降
if (getChar){
ResultStr resultStr = strList.get(0);
resultStr.push(charArray[n]);
}
}
}
for (int j = 0; j < strList.size(); j++){
ResultStr resultStr = strList.get(j);
char[] answerArray = new char[resultStr.strArray.size()];
for (int a = 0; a < resultStr.strArray.size(); a++){
answerArray[a] = resultStr.strArray.get(a);
}
String answer = String.valueOf(answerArray);
System.out.println(answer);
empty = false;
}
if(empty){
System.out.println("");
}
}
}
class ResultStr {
int numOfW;
LinkedList<Character> strArray;
ResultStr(int num) {
numOfW = num;
strArray = new LinkedList<Character>();
}
void push(char chars){
strArray.push(chars);
}
}
kenji_shioya