結果
問題 | No.2419 MMA文字列2 |
ユーザー |
![]() |
提出日時 | 2023-08-21 15:11:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 694 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 43,320 KB |
実行使用メモリ | 23,672 KB |
最終ジャッジ日時 | 2024-12-15 03:56:26 |
合計ジャッジ時間 | 1,861 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
/* -*- coding: utf-8 -*-** 2419.cc: No.2419 MMA文字列2 - yukicoder*/#include<cstdio>#include<cstring>#include<algorithm>using namespace std;/* constant */const int MAX_N = 200000;/* typedef */typedef long long ll;/* global variables */char s[MAX_N + 4];int qs[26], rs[MAX_N + 1][26];/* subroutines *//* main */int main() {scanf("%s", s);int n = strlen(s);for (int i = n - 1; i >= 0; i--) {copy(rs[i + 1], rs[i + 1] + 26, rs[i]);rs[i][s[i] - 'A']++;}ll sum = 0;for (int i = 0; i < n; i++) {int si = s[i] - 'A';sum += (ll)qs[si] * (n - (i + 1) - rs[i + 1][si]);qs[si]++;}printf("%lld\n", sum);return 0;}