結果
問題 | No.2738 CPC To F |
ユーザー |
👑 |
提出日時 | 2024-04-20 10:15:52 |
言語 | Lua (LuaJit 2.1.1734355927) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 60 ms |
コンパイル使用メモリ | 6,948 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 05:45:52 |
合計ジャッジ時間 | 899 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 22 |
ソースコード
local bc = string.byte("C", 1) local bp = string.byte("P", 1) local bt = string.byte("T", 1) local bf = string.byte("F", 1) local n = io.read("*n", "*l") local s = io.read() local cnt = 0 local pos = 1 while pos <= n - 4 do local found = false if s:byte(pos) == bc and s:byte(pos + 1) == bp and s:byte(pos + 2) == bc and s:byte(pos + 3) == bt then if s:byte(pos + 4) == bf then cnt = cnt + 1 pos = pos + 5 found = true elseif pos <= n - 6 then if s:byte(pos + 4) == bc and s:byte(pos + 5) == bp and s:byte(pos + 6) == bc then cnt = cnt + 1 pos = pos + 7 found = true end end end if not found then pos = pos + 1 end end print(cnt)