Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //214
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <math.h>
- #include <string>
- #include <algorithm>
- #include <climits>
- #include <regex>
- using namespace std;
- int main()
- {
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- smatch res;
- string s;
- regex regular("(\\(\\#*\\)|\\{\\#*\\})");
- int i = 1;
- while (getline(cin, s))
- {
- int k = 1;
- while (regex_search(s, res, regular))
- {
- s[res.position()] = '#';
- int c = res.position();
- while (s[c] == '#')
- c++;
- s[c] = '#';
- }
- int b = 0;
- int e = -1;
- for (int j = 0;j < s.length();j++)
- {
- if (s[j] == '#')
- if (e - b < 0)
- {
- b = j;e = j;
- }
- else
- e++;
- else
- if (e - b >= 0)
- {
- cout << i << " " << b + 1 << " " << e + 1 << endl;
- b = 0;e = -1;
- }
- }
- if (e - b >= 0)
- cout << i << " " << b + 1 << " " << e + 1<< endl;
- cout << endl;
- i++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement