結果
問題 | No.672 最長AB列 |
ユーザー | tac |
提出日時 | 2019-07-25 20:32:55 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 935 bytes |
コンパイル時間 | 1,452 ms |
コンパイル使用メモリ | 168,924 KB |
実行使用メモリ | 22,060 KB |
最終ジャッジ日時 | 2023-09-15 00:05:49 |
合計ジャッジ時間 | 2,642 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
15,880 KB |
testcase_01 | AC | 9 ms
15,812 KB |
testcase_02 | AC | 9 ms
15,836 KB |
testcase_03 | AC | 9 ms
15,848 KB |
testcase_04 | WA | - |
testcase_05 | AC | 9 ms
15,832 KB |
testcase_06 | AC | 9 ms
16,088 KB |
testcase_07 | AC | 9 ms
15,852 KB |
testcase_08 | AC | 9 ms
15,892 KB |
testcase_09 | AC | 28 ms
22,060 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 16 ms
17,032 KB |
testcase_14 | WA | - |
testcase_15 | AC | 16 ms
17,340 KB |
testcase_16 | AC | 16 ms
17,028 KB |
testcase_17 | AC | 24 ms
18,992 KB |
testcase_18 | WA | - |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pii pair<int, int> #define eb emplace_back #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < n; ++i) #define rep3(i, l, n) for (int i = l; i < n; ++i) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define out(a) cout << a << endl #define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl #define SZ(v) (int)v.size() #define inf (int)(1e9+7) vector<int> v[500001]; int main() { string s; cin >> s; int table[200001]; fill_n(table, 200001, -1); table[0] = 300000; rep(i, SZ(s)) { if (s[i] == 'A') table[i + 1] = table[i] + 1; else table[i + 1] = table[i] - 1; v[table[i + 1]].eb(i); } int ans = 0; rep(i, 500001) { if (SZ(v[i]) < 2) continue; chmax(ans, v[i][SZ(v[i]) - 1] - v[i][0]); } out(ans); }