結果

問題 No.2234 palindromer
ユーザー irohasu19_irohasu19_
提出日時 2023-03-11 20:06:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,603 bytes
コンパイル時間 2,098 ms
コンパイル使用メモリ 204,000 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 10:15:17
合計ジャッジ時間 2,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h> 
#define repr(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,n) for(int i=0;i<n;i++) 
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b) 
#define reprev(i,n) reprrev(i,0,n) 
#define _GLIBCXX_DEBUG 
#define int long long         
using ll = long long; 
using ull = unsigned long long; 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } 
const ll mod = 1e9+7; 
void chmod(ll &M){ 
  if(M >= mod) M %= mod; 
  else if(M < 0){ 
     M += (abs(M)/mod + 1)*mod; 
    M %= mod; 
} 
} 

int getl(int i, int N) { return i==0? N-1:i-1; }; 
int getr(int i, int N) { return i==N-1? 0:i+1; }; 
long long GCD(long long a, long long b) { 
  if (b == 0) return a; 
  else return GCD(b, a % b); 
} 
using namespace std; 
using Graph = vector<vector<int>>;

signed main() {
  string A; cin >> A;
  int n = A.length();
  int ind_pa = n-2; 
  int count = 1;
  rep(i, n) {
    int tmp = 0;
    int a = i-1, b = i+1;
    while(a >= 0 && b <= n-1) {
      if(A[a]==A[b]) { 
        tmp++;
        a--; b++;
        }
      else break;
    } 
    cerr << tmp << " " << b << endl;
    if(tmp > count && b == n) {
      cerr << tmp << endl;
      count = tmp;
      ind_pa = a; 
    } 
  }
  if(count == n/2) {
    cout << A << endl;
    return 0;
  }
  string ans = "";
  string A_ = A.substr(0, ind_pa+1);
  string B_ = A.substr(ind_pa+1, count);
  ans += A_; ans += B_;
  reverse(A_.begin(), A_.end());
  ans += A_;
  cout << ans << endl;
  
  
  }
0