結果
| 問題 |
No.559 swapAB列
|
| コンテスト | |
| ユーザー |
mmn15277198
|
| 提出日時 | 2020-09-11 04:58:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 503 bytes |
| コンパイル時間 | 930 ms |
| コンパイル使用メモリ | 90,932 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 13:08:10 |
| 合計ジャッジ時間 | 1,602 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
const long long mod = 1e9 + 7;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string s;
cin >> s;
int n = s.size();
int cnt_b = 0;
int ans = 0;
for(int i = n - 1; i >= 0; i--){
if(s[i] == 'B'){
ans += abs(i - n) - 1 - cnt_b;
cnt_b++;
}
}
cout << ans << endl;
return 0;
}
mmn15277198