結果
| 問題 |
No.1617 Palindrome Removal
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2021-07-22 22:07:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 638 ms |
| コンパイル使用メモリ | 74,644 KB |
| 最終ジャッジ日時 | 2025-01-23 06:46:34 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int main(){
string S; cin >> S;
string rS = S;
reverse(S.begin(),S.end());
if(S != rS){
cout << S.size() << "\n";
return 0;
}
if(S == string(S.size(),S[0])){
if(S.size() % 2 == 0) cout << "0\n";
else cout << "-1\n";
return 0;
}
if(S.size() == 3){
cout << "-1\n";
return 0;
}
cout << (S.size() - 2) << "\n";
return 0;
}
Nachia