Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- constexpr int N = 1e3 + 5;
- string s;
- vector<string> listString;
- void Read()
- {
- cin >> s;
- }
- bool IsDigit(char c)
- {
- return c >= '0' && c <= '9';
- }
- void Solve()
- {
- for (int i = 0, j = 0; i < s.length(); i = j)
- {
- // Nếu s[i] và s[j] cùng là chữ số hoặc không cùng là chữ số
- // thì hai kí tự này thuộc cùng một xâu
- while (j < s.length() && IsDigit(s[i]) == IsDigit(s[j]))
- ++j;
- string tempString = "";
- for (int t = i; t < j; ++t)
- tempString.push_back(s[t]);
- if (IsDigit(tempString[0])) // Nếu xâu chỉ gồm các chữ số
- listString.push_back(tempString);
- }
- for (string &number : listString)
- {
- while (number[0] == '0')
- number.erase(0, 1);
- }
- int answer = 0;
- sort(listString.begin(), listString.end());
- for (int i = 0; i < listString.size(); ++i)
- if (i == 0 || listString[i] != listString[i - 1])
- ++answer;
- cout << answer;
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- Read();
- Solve();
- }
- /*
- abc123abc2a3a1
- 4
- as00023dkrf23smk1asd23sam09aa9
- 3
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement