結果

問題 No.559 swapAB列
ユーザー hiyori
提出日時 2017-08-25 22:42:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 65,264 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-15 16:04:31
合計ジャッジ時間 1,019 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

int main()
{
    string s;
    cin>>s;
    int tmp,cnt=0;
    for(int i=0; i<s.length(); i++) {
        if(s[i]=='A') { continue; }
        else if(s[i]=='B' && s[i+1]=='B') {
            continue;
        }
        else if(s[i]=='B' && i!=s.length()-1) {
            tmp=s[i];
            s[i]=s[i+1];
            s[i+1]=tmp;
            i=0; cnt++;
        }
    }
    cout << cnt << endl;
    return 0;

}
0