結果

問題 No.2234 palindromer
ユーザー wanuiwanui
提出日時 2023-03-03 21:30:59
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,608 bytes
コンパイル時間 2,296 ms
コンパイル使用メモリ 202,240 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-17 22:22:44
合計ジャッジ時間 3,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// clang-format off
using namespace std; using ll=long long; using ull=unsigned long long; using pll=pair<ll,ll>; const ll INF=4e18;
void print0(){}; template<typename H,typename... T> void print0(H h,T... t){cout<<h;print0(t...);}
void print(){print0("\n");}; template<typename H,typename... T>void print(H h,T... t){print0(h);if(sizeof...(T)>0)print0(" ");print(t...);}
void perr0(){}; template<typename H,typename... T> void perr0(H h,T... t){cerr<<h;perr0(t...);}
void perr(){perr0("\n");}; template<typename H,typename... T>void perr(H h,T... t){perr0(h);if(sizeof...(T)>0)perr0(" ");perr(t...);}
void ioinit() { cout<<fixed<<setprecision(15); cerr<<fixed<<setprecision(6); ios_base::sync_with_stdio(0); cin.tie(0); }
#define debug1(a) { cerr<<#a<<":"<<a<<endl; }
#define debug2(a,b) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<endl; }
#define debug3(a,b,c) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<endl; }
#define debug4(a,b,c,d) { cerr<<#a<<":"<<a<<" "<<#b<<":"<<b<<" "<<#c<<":"<<c<<" "<<#d<<":"<<d<<endl; }
// clang-format on

bool ispalin(string s) {
    ll n = s.size();
    for (ll i = 0; i < n; i++) {
        ll j = n - i - 1;
        if (i > j) break;
        if (s[i] != s[j]) return false;
    }
    return true;
}
int main() {
    ioinit();
    string s;
    cin >> s;
    ll n = s.size();
    for (ll k = 0; k < n; k++) {
        string t = s;
        for (ll i = k - 1; i >= 0; i--) {
            t.push_back(s[i]);
        }
        //        debug1(t);
        if (ispalin(t)) {
            print(t);
            return 0;
        }
    }

    return 0;
}
0