Advertisement
erfanul007

Untitled

Jan 11th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<vi> vvi;
  8. typedef pair<int,int> pii;
  9. typedef vector< pii > vpii;
  10. typedef set<int> sti;
  11.  
  12. #define pb push_back
  13. #define pob pop_back
  14. #define mp make_pair
  15. #define ff first
  16. #define ss second
  17. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  18. #define loop(i,y) for(int i=0; i<int(y); i++)
  19. #define rloop(i,y) for(int i=int(y)-1; i>=0; i--)
  20. #define read() freopen("input.txt", "r", stdin)
  21. #define write() freopen("output.txt", "w", stdout)
  22. #define cspf(i) printf("Case %d: ", i)
  23. /// Constants
  24. #define eps 1e-9
  25. #define PI acos(-1.0) // 3.1415926535897932
  26. char s[500009];
  27. int main()
  28. {
  29. scanf("%s",s);
  30. int i,ln,sz=0,sb=0,eb=0,fb=0,lb=0;
  31. ln=strlen(s);
  32. for(i=0;i<ln;i++){
  33. if(fb==0){
  34. if(s[i]=='['){
  35. sb=i;
  36. fb++;
  37. }
  38. }
  39. if(s[i]==']'){
  40. eb=i;
  41. lb++;
  42. }
  43. }
  44. if(sb+3>eb || fb==0 || lb==0){
  45. cout<<"-1"<<endl;
  46. return 0;
  47. }
  48. sz+=2;
  49. int c1=0,c2=0,fc=0,lc=0;
  50. for(i=sb+1;i<eb;i++){
  51. if(fc==0){
  52. if(s[i]==':'){
  53. c1=i;
  54. fc++;
  55. continue;
  56. }
  57. }
  58. if(s[i]==':'){
  59. c2=i;
  60. lc++;
  61. }
  62. }
  63. if(c1+1>c2 || fc==0 || lc==0){
  64. cout<<"-1"<<endl;
  65. return 0;
  66. }
  67. sz+=2;
  68. for(i=c1+1;i<c2;i++){
  69. if(s[i]=='|')
  70. sz++;
  71. }
  72. cout<<sz<<endl;
  73. return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement