305862: CF1101B. Accordion
Memory Limit:256 MB
Time Limit:3 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Accordion
题意翻译
题意简述 给出一个字符串,试在其中删除一些字符,使得最后的串变为满足以下条件的串且长度最大: 长度大于等于$4$;第一个字符为$'['$;最后一个字符为$']'$;第二个字符和倒数第二个字符为$':'$;其余字符全部为$'|'$. 输入格式 一行一个字符串 输出格式 如果存在满足条件的串,输出它的最长长度,否则输出```-1```题目描述
An accordion is a string (yes, in the real world accordions are musical instruments, but let's forget about it for a while) which can be represented as a concatenation of: an opening bracket (ASCII code $ 091 $ ), a colon (ASCII code $ 058 $ ), some (possibly zero) vertical line characters (ASCII code $ 124 $ ), another colon, and a closing bracket (ASCII code $ 093 $ ). The length of the accordion is the number of characters in it. For example, \[::\], \[:||:\] and \[:|||:\] are accordions having length $ 4 $ , $ 6 $ and $ 7 $ . (:|:), {:||:}, \[:\], \]:||:\[ are not accordions. You are given a string $ s $ . You want to transform it into an accordion by removing some (possibly zero) characters from it. Note that you may not insert new characters or reorder existing ones. Is it possible to obtain an accordion by removing characters from $ s $ , and if so, what is the maximum possible length of the result?输入输出格式
输入格式
The only line contains one string $ s $ ( $ 1 \le |s| \le 500000 $ ). It consists of lowercase Latin letters and characters \[, \], : and |.
输出格式
If it is not possible to obtain an accordion by removing some characters from $ s $ , print $ -1 $ . Otherwise print maximum possible length of the resulting accordion.
输入输出样例
输入样例 #1
|[a:b:|]
输出样例 #1
4
输入样例 #2
|]:[|:]
输出样例 #2
-1