#include <bits/stdc++.h>
using namespace std;
string s;
signed main() {
cin >> s;
string t(s.size(), ' ');
reverse_copy(s.begin(), s.end(), t.begin()); // 反转用于 find
int res = 0, l = s.find('['), r = s.size() - 1 - t.find(']'); // 找 '['、']'
// cout << l << ' ' << r << '\n';
if (r == -1 || l == -1 || r - l < 3) return cout << -1, 0;
l++, r--;
while (l <= r && s[l] != ':') l++;
while (l <= r && s[r] != ':') r--;
// 找两个 ':'
// cout << l << ' ' << r << '\n';
if (r - l < 1) return cout << -1, 0;
while (l <= r)
if (s[l++] == '|') res++;
cout << res + 4;
}
WA on Test#29,输入数据太长 CF 只给了前一小段,如下:
[::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::...
答案:4,输出:-1。是 STL 哪里 G 了吗??