結果
問題 | No.1617 Palindrome Removal |
ユーザー |
![]() |
提出日時 | 2021-07-22 21:33:07 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 431 bytes |
コンパイル時間 | 1,810 ms |
コンパイル使用メモリ | 196,056 KB |
最終ジャッジ日時 | 2025-01-23 06:12:50 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> int main() { using namespace std; cin.tie(nullptr)->sync_with_stdio(false); string s; cin >> s; int n = size(s); if (count(begin(s), end(s), s[0]) == n) { cout << (n & 1 ? -1 : 0) << '\n'; exit(0); } if (s != string(rbegin(s), rend(s))) { cout << n << '\n'; exit(0); } if (n == 3) { cout << "-1\n"; exit(0); } cout << n - 2 << '\n'; }