結果

問題 No.559 swapAB列
ユーザー hamrayhamray
提出日時 2017-11-23 22:42:05
言語 C++11
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 345 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 159,104 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-27 05:58:45
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
double intse[80];
int main(){  
    int cnt = 0, ans = 0;
    string S; cin >> S;
    for(int i = S.size() - 1; i>=0; i--){
        if(S[i] == 'A'){
            cnt++;
        }
        if(S[i] == 'A' && S[i-1] == 'B'){
            ans += cnt;
        }
    }
    cout << ans << endl;
    return 0;
}
0