Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <iomanip>
- #include <math.h>
- #include <string>
- #include <vector>
- #include <queue>
- #include <stack>
- #include <map>
- #include <set>
- using namespace std;
- struct help
- {
- int count, max_len;
- };
- int main()
- {
- string s;
- vector<help> count;
- help h;
- h.count = 0;
- h.max_len = 0;
- count.push_back(h);
- int max_len = 0, max_count_word = 0;
- while (cin >> s)
- {
- int l = 0, r = s.size() - 1, n = s.size();
- if (s[r] == '.' || s[r] == '?' || s[r] == '!' || s[r] == ',')
- {
- r--;
- n--;
- }
- bool b = true;
- while (l < r)
- {
- if (s[l] != s[r])
- {
- b = false;
- break;
- }
- l++;
- r--;
- }
- int last = count.size() - 1;
- if (b)
- {
- count[last].count++;
- count[last].max_len = max(count[last].max_len, n);
- }
- n = s.size() - 1;
- if (s[n] == '.' || s[n] == '?' || s[n] == '!')
- {
- max_count_word = max(max_count_word, count[last].count);
- count.push_back(h);
- }
- }
- vector<int> v1;
- for (int i = 0; i < count.size(); i++)
- if (max_count_word == count[i].count)
- v1.push_back(i);
- for (int i = 0; i < v1.size(); i++)
- max_len = max(max_len, count[v1[i]].max_len);
- vector<int> v2;
- for (int i = 0; i < v1.size(); i++)
- if (count[v1[i]].max_len == max_len)
- v2.push_back(v1[i]);
- int ans_i = v2[0];
- cout << ans_i + 1 << endl;
- cout << count[ans_i].count << ' ' << count[ans_i].max_len << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement