結果

問題 No.342 一番ワロタww
ユーザー butchi_ybutchi_y
提出日時 2016-02-12 23:41:01
言語 JavaScript
(node v21.7.1)
結果
AC  
実行時間 72 ms / 5,000 ms
コード長 1,035 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 39,552 KB
最終ジャッジ日時 2024-04-21 01:18:18
合計ジャッジ時間 2,055 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
39,424 KB
testcase_01 AC 70 ms
39,424 KB
testcase_02 AC 72 ms
39,552 KB
testcase_03 AC 69 ms
39,168 KB
testcase_04 AC 69 ms
39,168 KB
testcase_05 AC 71 ms
39,296 KB
testcase_06 AC 71 ms
39,168 KB
testcase_07 AC 71 ms
39,424 KB
testcase_08 AC 70 ms
39,296 KB
testcase_09 AC 69 ms
39,424 KB
testcase_10 AC 69 ms
39,168 KB
testcase_11 AC 71 ms
39,168 KB
testcase_12 AC 69 ms
39,424 KB
testcase_13 AC 69 ms
39,552 KB
testcase_14 AC 70 ms
39,296 KB
testcase_15 AC 71 ms
39,296 KB
testcase_16 AC 71 ms
39,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

function Main(input) {
  var arr, ret, i, len, trimStr;

  trimStr = trim(input);

  wlen = wLength(trimStr);
  if(wlen === 0) {
    console.log('');
    return;
  }

  arr = trimStr.split(wrep(wlen));

  len = (arr || []).length;
  for(i = 0; i < len - 1; i++) {
    if(arr[i] !== '') {
      var tmpArr = arr[i].split('w');
      var line = last(tmpArr);
      console.log(line);
    }
  }
}

// "w"のlength回の繰り返し
function wrep(length) {
  return (new Array(length + 1)).join('w');
}

// 文字列の中で"w"が一番長く連続する回数
function wLength(str) {
  var arr, ret, i, len;

  arr = str.match(/w+/g);
  len = (arr || []).length;
  ret = 0;
  for(i = 0; i < len; i++) {
    if(arr[i].length > ret) {
      ret = arr[i].length;
    }
  }

  return ret;
}

function last(arr) {
  return arr[arr.length - 1];
}

// 先頭から続く「w」を削除する
function trim(str) {
  return str.replace(/^w+/, '');
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
0