結果
問題 | No.2419 MMA文字列2 |
ユーザー |
![]() |
提出日時 | 2023-08-19 12:55:44 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 783 bytes |
コンパイル時間 | 2,018 ms |
コンパイル使用メモリ | 103,552 KB |
実行使用メモリ | 58,240 KB |
最終ジャッジ日時 | 2024-11-29 05:56:44 |
合計ジャッジ時間 | 3,272 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;public class Hello{static void Main(){var s = Console.ReadLine().Trim();getAns(s);}static void getAns(string s){var n = s.Length;var a = new long[26, n];for (int i = 0; i < 26; i++){if (s[0] - 'A' == i) a[i, 0] = 1;for (int j = 1; j < n; j++){a[i, j] = a[i, j - 1];if (s[j] - 'A' == i) a[i, j]++;}}var ans = 0L;for (int i = 1; i < n - 1; i++){var t = s[i] - 'A';if (a[t, i - 1] < 1) continue;var ww = n - 1 - i - (a[t, n - 1] - a[t, i]);ans += ww * (a[t, i - 1]);}Console.WriteLine(ans);}}