結果
| 問題 |
No.559 swapAB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-07 22:37:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 449 bytes |
| コンパイル時間 | 410 ms |
| コンパイル使用メモリ | 55,380 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 04:53:25 |
| 合計ジャッジ時間 | 1,069 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 4 WA * 3 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
string s;
cin>>s;
int i;
int Na=0;
int Nb=0;
size_t sLen=s.length();
for (i=0;i<sLen;i++){
if (s[i]=='A'){
Na++;
}else{
Nb++;
}
}
size_t j=Na;
size_t aw=0;
for (i=0;i<sLen-Nb;i++){
if (s[i]=='B'){
for (;j<sLen;j++){
if (s[j]=='A'){
s[i]='A';
s[j]='B';
aw+=j-i;
}
}
}
}
cout<<aw<<endl;
return 0;
}