結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-04-13 22:41:15 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 658 bytes |
コンパイル時間 | 2,072 ms |
コンパイル使用メモリ | 194,720 KB |
最終ジャッジ日時 | 2025-01-05 10:04:40 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 1 TLE * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(n); i++) #define REP2(i,x,n) for(int i=x; i<(n); i++) #define ALL(n) begin(n),end(n) struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star; const long long INF = numeric_limits<long long>::max(); string S; int res{}; bool dfs( int i, string T ) { if( count( ALL( T ), 'A' ) == count( ALL( T ), 'B' ) ) { res = max( res, (int)T.size() ); } if( i == (int)S.size() - 1 ) { return 0; } return dfs( i + 1, T ) || dfs( i + 1, T += S[ i + 1 ] ); } int main() { cin >> S; dfs( 0, "" ); cout << res << endl; return 0; }