結果

問題 No.1617 Palindrome Removal
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-22 21:23:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 458 bytes
コンパイル時間 2,095 ms
コンパイル使用メモリ 204,344 KB
実行使用メモリ 5,132 KB
最終ジャッジ日時 2023-09-24 15:25:34
合計ジャッジ時間 3,524 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,380 KB
testcase_01 AC 24 ms
5,100 KB
testcase_02 AC 23 ms
5,072 KB
testcase_03 AC 22 ms
5,040 KB
testcase_04 AC 26 ms
5,132 KB
testcase_05 AC 21 ms
4,824 KB
testcase_06 AC 49 ms
5,080 KB
testcase_07 AC 31 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 43 ms
5,044 KB
testcase_11 AC 36 ms
5,064 KB
testcase_12 AC 45 ms
5,132 KB
testcase_13 AC 46 ms
5,092 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string s; cin>>s;
    set<char> st;
    for(char c:s)st.insert(c);
    if(st.size()==1){
        if(s.size()%2==0)puts("0");
        else puts("-1");
    }
    else{
        string t=s;
        reverse(t.begin(),t.end());
        if(s==t){
            if(s.size()==3)puts("-1");
            else cout<<s.size()-2<<endl;
        }
        else cout<<s.size()<<endl;
    }
}
0