結果

問題 No.2234 palindromer
ユーザー tnakao0123tnakao0123
提出日時 2023-05-05 16:27:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 42,624 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 11:48:07
合計ジャッジ時間 1,111 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2234.cc:  No.2234 palindromer - yukicoder
 */

#include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 100;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

inline bool palindrome(int n, char t[]) {
  for (int i = 0, j = n - 1; i < j; i++, j--)
    if (t[i] != t[j]) return false;
  return true;
}

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  int k = 0;
  for (; k < n; k++)
    if (palindrome(n - k, s + k)) break;

  for (int i = 0; i < n; i++) putchar(s[i]);
  for (int i = k - 1; i >= 0; i--) putchar(s[i]);
  putchar('\n');
  
  return 0;
}
0