結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
focus
|
| 提出日時 | 2018-05-22 15:09:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 375 bytes |
| コンパイル時間 | 795 ms |
| コンパイル使用メモリ | 83,728 KB |
| 実行使用メモリ | 16,000 KB |
| 最終ジャッジ日時 | 2024-06-28 15:45:26 |
| 合計ジャッジ時間 | 2,067 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 5 |
ソースコード
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using ll = long long ;
using namespace std;
int main(){
string str;
map<ll,ll> m;
m[0] = 0;
ll ans=0,p=0;
cin >> str;
ll len = str.size();
for(ll i=1;i<=len;i++){
if(str[i-1]=='A') p++;
else p--;
if(m.count(p)) ans=(ans,i-m[p]);
if(!m.count(p)) m[p]=i;
}
cout << ans << endl;
return 0;
}
focus