結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2019-04-29 14:14:10 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 393 bytes |
| コンパイル時間 | 49 ms |
| コンパイル使用メモリ | 6,816 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 08:41:14 |
| 合計ジャッジ時間 | 1,190 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
local str = io.read()
local n = #str
local t = {}
for i = 1, n + 1 do t[i] = 0 end
for i = n, 1, -1 do
if(str:sub(i, i) == "w") then
t[i] = t[i + 1] + 1
else
t[i] = t[i + 1]
end
end
local tot = 0
local cpos = str:find("c")
while(cpos ~= nil) do
if(2 <= t[cpos]) then
tot = tot + math.floor(t[cpos] * (t[cpos] - 1) / 2)
end
cpos = str:find("c", cpos + 1)
end
print(tot)