結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-04-13 23:32:51 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,207 bytes |
コンパイル時間 | 870 ms |
コンパイル使用メモリ | 140,288 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-30 12:16:30 |
合計ジャッジ時間 | 1,536 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 6 |
ソースコード
#include <iostream> #include <fstream> #include <string> #include <cstring> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <functional> #include <cctype> #include <list> //#include <boost/multiprecision/cpp_int.hpp> #define BIT(a) (1 << (a)) using namespace std; //using namespace boost::multiprecision; long long MOD = 1000000007; long long mod_pow(long long x, long long n){ long long res = 1; for(int i = 0;i < 60; i++){ if(n >> i & 1) res = res * x % MOD; x = x * x % MOD; } return res; } char s[200005]; int cnt[400005]; int main(void){ cin >> s; int len = strlen(s); int Acnt = 0; int ans = 0; memset(cnt, -1, sizeof(cnt)); for (int i = 0; i < len; i++){ if (cnt[Acnt+200000] == -1){ cnt[Acnt+200000] = i; }else{ if (ans < i-cnt[Acnt+200000]) ans = i - cnt[Acnt+200000]; } if (s[i] == 'A'){ ++Acnt; } if (s[i] == 'B'){ --Acnt; } } cout << ans << endl; return 0; }