結果
| 問題 |
No.1535 五七五
|
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2021-06-19 19:25:15 |
| 言語 | Lua (LuaJit 2.1.1734355927) |
| 結果 |
AC
|
| 実行時間 | 354 ms / 2,000 ms |
| コード長 | 737 bytes |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 5,248 KB |
| 実行使用メモリ | 32,528 KB |
| 最終ジャッジ日時 | 2024-06-22 22:18:11 |
| 合計ジャッジ時間 | 4,542 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
local n = io.read("*n")
local a, b, c = io.read("*n", "*n", "*n", "*l")
local s = io.read()
local t = {}
for w in s:gmatch("%w+") do
table.insert(t, #w)
end
for i = 2, n do
t[i] = t[i - 1] + t[i]
end
local ret = 0
local offset = 0
local ap, bp, cp = 1, 1, 1
for i = 1, n do
while ap <= n and t[ap] < offset + a do
ap = ap + 1
end
if n < ap then
bp = ap
else
while bp <= n and t[bp] < t[ap] + b do
bp = bp + 1
end
end
if n < bp then
cp = bp
else
while cp <= n and t[cp] < t[bp] + c do
cp = cp + 1
end
end
if ap <= n and bp <= n and cp <= n
and t[cp] - t[bp] == c
and t[bp] - t[ap] == b
and t[ap] - offset == a then
ret = ret + 1
end
offset = t[i]
end
print(ret)