結果
| 問題 |
No.342 一番ワロタww
|
| コンテスト | |
| ユーザー |
Tsukasa_Type
|
| 提出日時 | 2018-02-17 15:50:43 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,172 bytes |
| コンパイル時間 | 2,340 ms |
| コンパイル使用メモリ | 78,192 KB |
| 実行使用メモリ | 54,584 KB |
| 最終ジャッジ日時 | 2024-06-24 12:11:28 |
| 合計ジャッジ時間 | 5,171 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 2 |
ソースコード
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
String s = sc.next();
String[] sentence = new String[100];
Arrays.fill(sentence,"");
int[] grass = new int[100];
int m = 0; //0なら文章長カウントモード、1なら草カウントモード
int n = 0; //現在何番目の文章と草を調べているか
int max_grass = -1; //最も長い草の長さ
StringBuilder sb = new StringBuilder();
for (int i=0; i<s.length(); i++) {
if (m==0 && s.charAt(i)!='w') {
sb.append(s.charAt(i));
}
else if (m==0 && s.charAt(i)=='w') {
sentence[n] = sb.toString();
sb.setLength(0);
m = 1;
i--;
}
else if (m==1 && s.charAt(i)=='w') {
grass[n]++;
max_grass = Math.max(max_grass,grass[n]);
}
else if (m==1 && s.charAt(i)!='w') {
m = 0;
n++;
i--;
}
}
if (s.contains("w")==false || s.replace("w","").equals("")) {System.out.println("");}
else {
for (int i=0; i<100; i++) {
if (grass[i]==max_grass) {
if (sentence[i].equals("")==false) {System.out.println(sentence[i]);}
}
}
}
}
}
Tsukasa_Type