|
|
back to boardAccepted Posted by Mikhail 12 Mar 2018 18:28 #include <bits/stdc++.h> using namespace std; #define re return #define pb push_back #define all(x) (x).begin(), (x).end() #define fi first #define se second #define sqrt(x) sqrt(abs(x)) #define mp make_pair #define pi (3.14159265358979323846264338327950288419716939937510) #define fo(i, n) for(int i = 0; i < n; ++i) #define ro(i, n) for(int i = n - 1; i >= 0; --i) #define unique(v) v.resize(unique(all(v)) - v.begin()) template <class T> T abs (T x) { re x > 0 ? x : -x; } template <class T> T sqr (T x) { re x * x; } template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; } template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); } typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef double D; typedef long double ld; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vll; typedef unsigned long long ull; vi l, r; int main() { //freopen("input.txt", "r", stdin); string str; while (getline(cin, str)) { l.clear(), r.clear(); if (isalpha(str[0])) l.pb(0); fo(i, (int)str.size() - 1) { if (!isalpha(str[i]) && isalpha(str[i + 1])) l.pb(i + 1); if (isalpha(str[i]) && !isalpha(str[i + 1])) r.pb(i + 1); } if (isalpha(str.back())) r.pb(str.size()); fo(i, l.size()) reverse(str.begin() + l[i], str.begin() + r[i]); cout << str << '\n'; str.clear(); } } |
|
|