-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1101B.cpp
More file actions
34 lines (34 loc) · 819 Bytes
/
Copy path1101B.cpp
File metadata and controls
34 lines (34 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
long int ans=0,largest=0;char openbracket='[',closebracket=']',colon=':';
bool opened=false,closed=false;int colons = 0;string smallstr="";
vector<long int> ob,cb;vector< pair<long int, long int > >col;int pipes = 0;
for(long int i=0;i<s.length();i++){
// cout << s[i]<<" ";
if(s[i]==openbracket)
ob.push_back(i);
else if(s[i]==closebracket && col.size()>1)
cb.push_back(i);
else if(s[i]==colon && ob.size()>0)
col.push_back(make_pair(i,pipes));
else if(s[i]=='|' && col.size()>0){
pipes++;
}
}
int i=0;
{if(cb.size()>0){
for(i=col.size()-1;i>=0;i--){
if(col[i].first < cb[cb.size()-1])
break;
}}}
if(i>0){
cout << col[i].second+4<<endl;
}
else{
cout << -1 << endl;
}
//add 4 to end;
}