結果

問題 No.2419 MMA文字列2
ユーザー 👑 obakyanobakyan
提出日時 2023-08-12 13:49:08
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 604 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 5,460 KB
実行使用メモリ 148,640 KB
最終ジャッジ日時 2023-08-12 13:52:24
合計ジャッジ時間 8,389 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 140 ms
34,436 KB
testcase_13 AC 30 ms
9,876 KB
testcase_14 AC 266 ms
64,224 KB
testcase_15 AC 162 ms
40,180 KB
testcase_16 AC 277 ms
67,480 KB
testcase_17 AC 79 ms
21,800 KB
testcase_18 AC 294 ms
70,264 KB
testcase_19 AC 302 ms
72,860 KB
testcase_20 AC 88 ms
23,812 KB
testcase_21 AC 56 ms
17,792 KB
testcase_22 AC 596 ms
146,604 KB
testcase_23 AC 588 ms
146,608 KB
testcase_24 AC 604 ms
145,716 KB
testcase_25 AC 586 ms
145,668 KB
testcase_26 AC 61 ms
19,888 KB
testcase_27 AC 565 ms
148,640 KB
testcase_28 AC 601 ms
147,584 KB
testcase_29 AC 591 ms
147,576 KB
testcase_30 AC 599 ms
147,528 KB
testcase_31 AC 603 ms
147,628 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