結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2018-09-17 15:03:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 602 bytes |
コンパイル時間 | 514 ms |
コンパイル使用メモリ | 67,768 KB |
最終ジャッジ日時 | 2025-01-06 13:34:03 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 TLE * 10 |
ソースコード
#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; } } } } } cout << len << endl; return 0; }