結果
問題 | No.1617 Palindrome Removal |
ユーザー | Rubikun |
提出日時 | 2021-07-22 21:55:23 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 914 bytes |
コンパイル時間 | 1,609 ms |
コンパイル使用メモリ | 169,736 KB |
実行使用メモリ | 5,364 KB |
最終ジャッジ日時 | 2023-09-24 16:43:38 |
合計ジャッジ時間 | 3,432 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
5,112 KB |
testcase_01 | AC | 22 ms
5,216 KB |
testcase_02 | AC | 22 ms
5,364 KB |
testcase_03 | AC | 21 ms
5,116 KB |
testcase_04 | AC | 24 ms
5,100 KB |
testcase_05 | AC | 20 ms
4,688 KB |
testcase_06 | AC | 45 ms
5,288 KB |
testcase_07 | AC | 28 ms
4,424 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 42 ms
4,932 KB |
testcase_11 | AC | 38 ms
4,976 KB |
testcase_12 | AC | 45 ms
5,116 KB |
testcase_13 | AC | 47 ms
5,148 KB |
testcase_14 | AC | 2 ms
4,376 KB |
testcase_15 | AC | 1 ms
4,376 KB |
testcase_16 | AC | 2 ms
4,380 KB |
testcase_17 | AC | 1 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,380 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 1 ms
4,376 KB |
testcase_21 | AC | 1 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,376 KB |
testcase_23 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=1000000007,MAX=105,INF=1<<30; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); string S;cin>>S; string T=S; sort(all(T)); if(T[0]==T.back()){ if(si(S)&1) cout<<-1<<endl; else cout<<0<<endl; }else{ T=S; reverse(all(T)); if(S!=T){ cout<<si(S)<<endl; }else{ if(si(S)==3) cout<<-1<<endl; else cout<<si(S)-2<<endl; } } }