結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-05 04:50:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 456 bytes |
| コンパイル時間 | 2,172 ms |
| コンパイル使用メモリ | 191,900 KB |
| 最終ジャッジ日時 | 2025-01-10 06:40:31 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 5 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
string s; cin>>s;
int n=s.length();
int lo=0,hi=n/2+1;
while(hi-lo>1){
int mi=(lo+hi)/2;
bool ok=false;
int a=0,b=0;
rep(i,2*mi) (s[i]=='A'?a:b)++;
for(int i=2*mi;i<=n;i++){
if(a==b) ok=true;
if(i<n){
(s[i]=='A'?a:b)++;
(s[i-2*mi]=='A'?a:b)--;
}
}
if(ok) lo=mi;
else hi=mi;
}
printf("%d\n",2*lo);
return 0;
}