結果

問題 No.2419 MMA文字列2
ユーザー marble72
提出日時 2023-08-12 16:20:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 1,693 ms
コンパイル使用メモリ 173,212 KB
実行使用メモリ 13,040 KB
最終ジャッジ日時 2024-11-20 05:30:30
合計ジャッジ時間 11,356 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other AC * 4 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    int l = S.length();
    ll ans=0;
    map<int,int> ser;
    for(int i=0;i<l;i++){
        int s = (int)S[i];
        ser[s]++;
        int a = 'A';
        for(int j=0;j<26;j++){
            int c = a+i;
            if(s == c){
                continue;
            }
            if(ser[c] >= 2){
                int su = ser[c];
                ll pl = su*(su-1)/2;
                ans += pl;
            }
        }
    }
    cout << ans << endl;
}
0