fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <set>
  5. #include <cmath>
  6. #include <vector>
  7. #include <climits>
  8. #include <string>
  9. #include <algorithm>
  10. #include <sstream>
  11. using namespace std;
  12.  
  13. vector<string> split(string haystack, string needle) {
  14. vector<string> result;
  15. int startPos = 0;
  16. int foundPos = haystack.find(needle, startPos);
  17. while (foundPos != string::npos) {
  18. int count = foundPos - startPos;
  19. string token = haystack.substr(startPos, count);
  20. if (!token.empty()) {
  21. result.push_back(token);
  22. }
  23. startPos = foundPos + needle.length();
  24. foundPos = haystack.find(needle, startPos);
  25. }
  26. string token = haystack.substr(startPos, haystack.length() - startPos);
  27. if (!token.empty()) {
  28. result.push_back(token);
  29. }
  30. return result;
  31. }
  32.  
  33. string nameConvert(const string& name) {
  34. const string DELIMITER = " ";
  35. stringstream builder;
  36. auto parts = split(name, DELIMITER);
  37. for (auto part : parts) {
  38. part[0] = toupper(part[0]);
  39. transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
  40. builder << part << DELIMITER;
  41. }
  42. return builder.str();
  43. }
  44.  
  45. string dateConvert(const string& date) {
  46. const string DELIMITER = "/";
  47. stringstream builder;
  48. auto parts = split(date, DELIMITER);
  49. builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
  50. builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
  51. builder << parts[2];
  52. return builder.str();
  53. }
  54.  
  55. string maxValue(int m, int s) {
  56. string result = "";
  57. while (m--) {
  58. if (s > 9) {
  59. result = result + '9';
  60. s = s - 9;
  61. }
  62. else {
  63. result = result + to_string(s);
  64. s = 0;
  65. }
  66. }
  67. return result;
  68. }
  69. string minValue(int m, int s) {
  70. string result = "";
  71. s--;
  72. while (m--) {
  73. if (s > 9) {
  74. result = result + '9';
  75. s = s - 9;
  76. }
  77. else {
  78. result = to_string(s) + result;
  79. s = 0;
  80. }
  81. }
  82. result[0]++;
  83. return result;
  84. }
  85.  
  86. int main() {
  87. ios_base::sync_with_stdio(false);
  88. cin.tie(NULL);
  89.  
  90. string s;cin >> s;
  91.  
  92. for (int i = 0;i < s.length();i++) {
  93. if (!isdigit(s[i])) {
  94. s[i] = ' ';
  95. }
  96. }
  97. auto parts = split(s, " ");
  98. vector<string> v;
  99. for (auto part : parts) {
  100. while (part[0] == '0') {
  101. part.erase(0, 1);
  102. }
  103. if (part.size() != 0) {
  104. v.push_back(part);
  105. }
  106. }
  107.  
  108. sort(v.begin(), v.end(), [](string a, string b) {
  109. if (a.length() != b.length()) {
  110. return a.length() < b.length();
  111. }
  112. return a < b;
  113. });
  114.  
  115. if (v.size() == 0) {
  116. cout << 0;
  117. }
  118. else {
  119. cout << *(v.rbegin());
  120. }
  121. return 0;
  122. }
  123.  
  124.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
Standard output is empty