fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. string super_reduced_string(string s){
  6. // Complete this function
  7. while(1)
  8. {
  9. int f=0;
  10. for(int i=0;i<s.length()-1;i++)
  11. {
  12. if(s[i]==s[i+1])
  13. {
  14. f=1;
  15. s.erase(s.begin()+i);
  16. s.erase(s.begin()+i);
  17. break;
  18. }
  19. }
  20. if(f==0)
  21. break;
  22. }
  23. if(s.size()==0)
  24. {
  25. return "Empty String";
  26. }
  27. else
  28. return s;
  29. }
  30.  
  31. int main() {
  32. string s;
  33. cin >> s;
  34. string result = super_reduced_string(s);
  35. cout << result << endl;
  36. return 0;
  37. }
  38.  
Runtime error #stdin #stdout #stderr 0s 2872KB
stdin
aa
stdout
Standard output is empty
stderr
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_S_create