はまやんはまやんはまやん

hamayanhamayan's blog

Palindromic Supersequence [ICM Technex 2018 and Codeforces Round #463 (Div. 1 + Div. 2, combined) A]

http://codeforces.com/contest/932/problem/A

文字列Aがある。
これについて以下の条件を満たす文字列Bを答えよ。

  • Bの(連続でなくてもいい)部分列にAが含まれる
  • Bは回文
  • Bの長さは10^4以下

解法

http://codeforces.com/contest/932/submission/35299778

よくよく考えると、B=A+reverse(A)がこれを満たす。

string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    string ans = S;
    reverse(all(S));
    ans += S;

    cout << ans << endl;
}