Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <queue>
- #include <unordered_map>
- #include <iomanip>
- #include <stack>
- #include <set>
- #define int long long
- using namespace std;
- #pragma comment(linker, "/stack:200000000")
- #pragma GCC optimize("Ofast")
- #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
- signed main() {
- string s;
- cin >> s;
- int n = (int)s.size();
- vector<string> str;
- vector<int> space;
- string now = "";
- for (int i = 0; i < n; ++i){
- if (s[i] == '.'){
- if (now == ""){
- continue;
- }
- str.push_back(now);
- space.push_back(now.size());
- now = "";
- }
- else{
- now += s[i];
- }
- }
- if (now != ""){
- str.push_back(now);
- space.push_back(now.size());
- }
- sort(str.begin(), str.end());
- int j = 0;
- for (int i = 0; i < n; ++i){
- if (s[i] == '.'){
- cout << s[i];
- continue;
- }
- cout << str[j];
- i += space[j] - 1;
- ++j;
- }
- }
- /*
- 5
- aca
- aba
- aba
- cab
- bac
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement