結果
問題 | 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 = 0local pos = 1while pos <= n - 4 dolocal found = falseif s:byte(pos) == bcand s:byte(pos + 1) == bpand s:byte(pos + 2) == bcand s:byte(pos + 3) == bt thenif s:byte(pos + 4) == bf thencnt = cnt + 1pos = pos + 5found = trueelseif pos <= n - 6 thenif s:byte(pos + 4) == bcand s:byte(pos + 5) == bpand s:byte(pos + 6) == bc thencnt = cnt + 1pos = pos + 7found = trueendendendif not found thenpos = pos + 1endendprint(cnt)