結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2018-09-17 15:09:54 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 684 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 118,272 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-30 12:42:24 |
合計ジャッジ時間 | 28,460 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 1 TLE * 9 |
ソースコード
#include<iostream> #include<string> using namespace std; int main() { string str; cin >> str; int str_cout=0; int now=0; int len=0; if (str.size() == 1) { cout << len << endl; return 0; } else { for (int i = 0;i < str.size()-1;i++) { str_cout = 0; now = i; for (int j = i;j < str.size();j++) { char buf = str[j]; if (buf == 'A')str_cout++; else if (buf == 'B')str_cout--; if (j > i && str_cout == 0) { int buflen = (j - now) + 1; if (buflen > len) { len = buflen; now = j; } } } if (str_cout == str.size()) { cout << "200000" << endl; return 0; } } } cout << len << endl; return 0; }