grouping of round and square sections is given. You can change the arrangement by playing out the accompanying activities: shift the bearing of a section from opening to shutting as well as the other way around without changing the type of the section: for example you can change '(' to ')' and ')' to '('; you can change '[' to ']' and ']' to '

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Please only in c++. With correct output else downvote.

 

grouping of round and square sections is given. You can change the arrangement by playing out the accompanying activities: shift the bearing of a section from opening to shutting as well as the other way around without changing the type of the section: for example you can change '(' to ')' and ')' to '('; you can change '[' to ']' and ']' to '['. The activity costs 0 burles. 

change any square section to adjust section having a similar course: for example you can change '[' to '(' yet not from '(' to '['; comparably, you can change ']' to ')' however not from ')' to ']'. The activity costs 1 burle. The activities can be acted in any request quite a few times. You are given a string s of the length n and q inquiries of the kind "l r" where 1≤l<r≤n. For each substring s[l… r], track down the base expense to pay to make it a right section grouping. It is ensured that the substring s[l… r] has an even length. 

The inquiries should be handled autonomously, for example the progressions made in the string for the response to an inquiry I don't influence the inquiries j (j>i). At the end of the day, for each question, the substring s[l… r] is given from the at first given string s. A right section grouping is an arrangement that can be worked agreeing the accompanying principles: an unfilled grouping is a right section succession; 

on the off chance that "s" is a right section grouping, the successions "(s)" and "[s]" are right section arrangements. in the event that "s" and "t" are right section arrangements, the grouping "st" (the link of the successions) is a right section arrangement. For example the arrangements "", "(()[])", "[()()]()" and "(())()" are right section groupings while "(", "[(])" and ")))" are not. 

Info :The principal line contains one whole number t (1≤t≤100) — the quantity of experiments. Then, at that point, t experiments follow. 

For each experiment, the main line contains a non-void string s containing just round ('(', ')') and square ('[', ']') sections. The length of the string doesn't surpass 106. The string contains no less than 2 characters.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education