結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
gt_ham_bass
|
| 提出日時 | 2018-04-13 23:25:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 417 bytes |
| コンパイル時間 | 1,033 ms |
| コンパイル使用メモリ | 56,312 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-06-27 19:39:14 |
| 合計ジャッジ時間 | 4,195 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 3 TLE * 1 -- * 9 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
int ans,ANS,f_ans;
string s,S;
int main() {
std::cin >> s;
int n = s.size();
for(int i = 0; i < n; i++){
for(int j = 1; i + j < n; j++){
S = s.substr(i,j);
ANS = 0;
for(int k = 0; k < j;k++){
if(S[k] == 'A') ANS++;
else if(S[k] == 'B') ANS--;
}
if(ANS == 0) ans = std::max(ans,j);
}
}
std::cout << ans << std::endl;
}
gt_ham_bass