Codeforces Global Round 4E (string, thinking)

#include <bits / STDC ++ H.>
the using namespace STD;
String S, A, B;
int main () {
CIN >> S;
int = n-s.size ();
int L = 0,. 1-n-= R & lt;
while (l <= r-3 ) {// no letters three consecutive identical, so there must be four characters within the same letter, i.e. palindromic
IF (S [L] == S [R & lt]) {
a.push_back (S [L]);
b.push_back (S [R & lt]);
L ++, r--;
}
the else IF (S [L] == S [-R & lt. 1]) {
a.push_back (S [L]) ;
b.push_back (S [R & lt-. 1]);
L ++, R- = 2;
}
the else IF (S [L +. 1] == S [R & lt]) {
a.push_back (S [L +. 1]);
b.push_back (S [R & lt]);
L = 2 +, r--;
}
the else IF (S [L +. 1] == S [-R & lt. 1]) {
a.push_back (S [L +. 1]);
b.push_back (S [R & lt-. 1]);
L = 2 +, R- = 2;
}
}
IF (R & lt> = L)
a.push_back (s [l]); // there remains a middle letter, coupled with its longer strings so that when the input string is small, with the middle may be such that more than half of a
reverse (b.rbegin (), b .rend ()); // + reverse iterator forward, equivalent to reverse (b.begin (), b.end ());
COUT << a << B;
return 0;
}

Guess you like

Origin www.cnblogs.com/ldudxy/p/11226516.html
Recommended