結果

問題 No.559 swapAB列
コンテスト
ユーザー sasa
提出日時 2025-03-18 17:11:51
言語 C
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 367 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 169 ms
コンパイル使用メモリ 38,848 KB
最終ジャッジ日時 2026-02-22 13:19:17
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>

int main(void){
	char str[12];
	scanf("%s",str);
	int len = strlen(str);
	
	
	int ele = 0;
	for(int i = len - 1;i >= 0;i --){
		if(str[i] != 'B'){
			ele = i;
			break;
		}
	}
	
	int count = 0;
	int ans = 0;
	for(int i = ele;i >= 0;i--){
		if(str[i] == 'B'){
			ans += (ele - count) - i;
			count++;
		}
	}
	printf("%d",ans);
}
0