結果
問題 |
No.559 swapAB列
|
ユーザー |
![]() |
提出日時 | 2017-10-08 18:15:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 556 bytes |
コンパイル時間 | 650 ms |
コンパイル使用メモリ | 82,148 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 05:43:24 |
合計ジャッジ時間 | 1,216 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 7 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<cstdio> #include<cstdlib> #include<string> #include<sstream> #include<cmath> #include<numeric> #include<map> #include<stack> #include<queue> using namespace std; int inf = 1000000000; int main(void) { string s; cin >> s; bool f = true; int cnt = 0; while( f ){ f = false; for(int i=0; i<s.size()-1; i++){ if( s[i] == 'B' && s[i+1] == 'A' ){ swap(s[i], s[i+1]); cnt++; f = true; } } } cout << cnt << endl; return 0; } // EOF