結果
問題 | No.2234 palindromer |
ユーザー |
|
提出日時 | 2023-03-04 10:01:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 1,309 ms |
コンパイル使用メモリ | 169,780 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 00:58:37 |
合計ジャッジ時間 | 1,887 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 13 |
ソースコード
#include <bits/stdc++.h> using namespace std; void solve(){ string s; cin >> s; for(int i = 0; i < s.size(); i++){ bool f = true; int l = i, r = s.size()-1; while(l < r){ if(s[l] != s[r]){ f = false; break; } l++; r--; } if(f){ string t = s.substr(0, i); reverse(t.begin(), t.end()); cout << s << t << "\n"; return; } } string t = s; reverse(t.begin(), t.end()); cout << s << t << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(0); // int t; // cin >> t; // while(t--){ // solve(); // } solve(); return 0; }