結果

問題 No.2419 MMA文字列2
ユーザー 👑 obakyanobakyan
提出日時 2023-08-12 13:49:08
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 5,504 KB
実行使用メモリ 165,888 KB
最終ジャッジ日時 2024-04-30 04:10:57
合計ジャッジ時間 9,591 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 136 ms
38,912 KB
testcase_13 AC 32 ms
9,728 KB
testcase_14 AC 292 ms
72,704 KB
testcase_15 AC 168 ms
45,312 KB
testcase_16 AC 321 ms
76,288 KB
testcase_17 AC 80 ms
24,064 KB
testcase_18 AC 335 ms
79,104 KB
testcase_19 AC 375 ms
78,208 KB
testcase_20 AC 90 ms
26,880 KB
testcase_21 AC 68 ms
19,712 KB
testcase_22 AC 738 ms
161,920 KB
testcase_23 AC 718 ms
161,920 KB
testcase_24 AC 711 ms
160,000 KB
testcase_25 AC 712 ms
159,872 KB
testcase_26 AC 69 ms
21,888 KB
testcase_27 AC 642 ms
165,888 KB
testcase_28 AC 694 ms
164,864 KB
testcase_29 AC 697 ms
164,992 KB
testcase_30 AC 699 ms
164,864 KB
testcase_31 AC 700 ms
164,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local s = io.read()
local n = #s
local one, two = {}, {}
one[1], two[1] = {}, {}
for i = 1, 26 do
  one[1][i], two[1][i] = 0LL, 0LL
end
local ans = 0LL
for i = 1, n do
  one[i + 1], two[i + 1] = {}, {}
  for j = 1, 26 do
    one[i + 1][j] = one[i][j]
    two[i + 1][j] = two[i][j]
  end
  local b = s:byte(i) - 64
  one[i + 1][b] = one[i][b] + 1LL
  two[i + 1][b] = two[i][b] + one[i][b]
  for j = 1, 26 do
    if j ~= b then
      ans = ans + two[i][j]
    end
  end
end
ans = tostring(ans):gsub("LL", "")
print(ans)
0