fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. string str;
  7. getline(cin,str);
  8. vector<int> tmp,tmp2;
  9. str="."+str+".";
  10. for_each(str.begin(), str.end(), [&](char& n){if (n == '.') tmp.push_back(&n - &str[0]);});
  11. tmp2.resize(tmp.size());
  12. copy(tmp.begin() + 1, tmp.end(),tmp2.begin());
  13. transform (tmp2.begin(), tmp2.end(), tmp.begin(), tmp2.begin(), std::minus<int>());
  14. auto pos = max_element(tmp2.begin(),tmp2.end());
  15. int poss = *(tmp.begin() + (pos - tmp2.begin())) + 1;
  16. copy(str.begin() + poss, str.begin() + poss + *pos, ostream_iterator<char>(cout));
  17. return 0;
  18. }
Success #stdin #stdout 0s 3476KB
stdin
aaaa bbb c. aaa bbb ccc. aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
stdout
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.