B. Accordion

B. Accordion

B.手风琴

time limit per test: 3 seconds
每次测试的时间限制:3秒

memory limit per test: 256 megabytes
每次测试的内存限制:256兆字节

input: standard input
输入:标准输入

output: standard output
产出:标准产出

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
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
表示为:开口括号(ASCII代码091)、冒号(ASCII代码058)的级联。一些(可能为零)垂直线

characters (ASCII code 124). another colon, and a closing bracket (ASCII code 093). The length of the accordion is the number of
字符(ASCII代码124)。另一个冒号和一个结束括号(ASCII代码093)。手风琴的长度是

characters in it.
characters in it.

For example, [: :], [ 1 :] and [:111 : ] are accordions having length 4, 6 and 7. (: 1:), {:11:}, [:].]:|1: [ are not
例如,[:]、[:\x{e76f}和[:111:]是长度分别为4、6和7的手风琴。

acordions.
阿科迪翁。

You are given a string 8. You want to transform it into an accordion by removing some (possibly zero) characters from it. Note that you may
您将得到一个字符串8。您希望通过从其中移除一些字符(可能为零),将其转换为手风琴。请注意,您可以

not insert new characters or reorder existing ones. Is it possible to obtain an accordion by removing characters from 8, and if so, what is the
不插入新字符或重新排序现有字符。是否可以通过从8中移除字符来获得手风琴,如果可以的话,

maximum possible length of the result?
结果的最大可能长度?

Input
输入

The only line contains one string 8(1 < |s|≤500000). It consists of lowercase Latin letters and characters [, ], : and 1.
唯一的一行包含一个字符串8(1<\x{e76f}}≤500000)。它由小写拉丁字母和字符[,]、:和1组成。

Output
输出量

If it is not possible to obtain an accordion by removing some characters from 8, print - 1. Otherwise print maximum possible length of the
如果无法通过从8中移除某些字符获得手风琴,则打印-1。否则,打印

resulting accordion.
导致手风琴。

掐头去尾,遍历


int main()
{
    string a;
    cin>>a;
    int sum=0;
    int b=a.size()-1;
   while(a[b]!=']')
   {   --b;
       if(b<0)
       {
           cout<<-1<

你可能感兴趣的:(cf,c++)