結果

問題 No.1617 Palindrome Removal
ユーザー RrrRrRRrRRrrRRrrRrrRrRRrRRrrRRrr
提出日時 2021-07-22 21:55:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,782 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 200,576 KB
実行使用メモリ 12,984 KB
最終ジャッジ日時 2023-09-24 16:44:19
合計ジャッジ時間 8,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<long long>>; // グラフ型
Graph G; // グラフ
using ll = long long;
using ld = long double;
using str = string;
#define nedl endl
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = long long(a); i<long long(b); i++)
#define cfs(n) cout<<fixed<<setprecision(n)
#define sor(v) sort(v.begin(), v.end())
// ll max = *max_element(v.begin(), v.end());
// ll min = min_element(v.begin(), v.end());

int main() {
    bool ans = false;
    bool kaibun = false;
    bool onaji = false;
    str S;
    cin >> S;
    ll ss = 0;
    for (ll i = 0; i < S.length() / 2; i++) {
        ss = S.length() - 1;
        if (S[i] == S[ss] - i) {
            kaibun = true;
        }
    }
    ss = S.length() - 1;
    ll jj;
    rep(j, ss) {
        jj = j + 1;
        if (S[j] != S[jj]) {
            onaji = true;
        }
    }
    if (onaji == true) {
        cout << 0 << endl;
    }
    else {
        if (kaibun == true) {
            bool kaibun2 = true;
            ll p, q, r, t;
            ll l;
            bool aru = false;
            bool arukamo = false;
            for (l = 2; l <= S.length(); l = l + 2) {
                for (p = 0; p < S.length() - 1; p++) {
                    for (q = p + 1; q < S.length(); q++) {
                        r = 0;
                        arukamo = true;
                        for (t = S.length() - 1; r > t; t--) {
                            if (r == p || r == q) {
                                r++;
                            }
                            if (t == p || t == q) {
                                t--;
                            }
                            if (r > t) {
                                break;
                            }
                            if (S[t] == S[r]) {

                            }
                            else {
                                arukamo = false;
                            }
                            if (arukamo == true) {
                                aru = true;
                            }
                            if (aru == true) {
                                break;
                            }
                            r++;
                        }
                        if (aru == true) {
                            break;
                        }
                    }
                    if (aru == true) {
                        break;
                    }
                }
                if (aru == true) {
                    break;
                }
            }
            cout << S.length() - l << endl;
        }
        else {
            cout << S.length() << endl;
        }
    }
}
0