結果
問題 | No.273 回文分解 |
ユーザー |
|
提出日時 | 2016-01-01 01:23:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 719 ms |
コンパイル使用メモリ | 91,544 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 13:33:39 |
合計ジャッジ時間 | 1,675 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>#include <deque>#include <string>#include <tuple>#include <functional>#include <numeric>#include <cmath>#include <iomanip>#include <map>#include <random>//#include "toollib.h"#define INT_MAX 2147483647#define Loop(i, n) for(int i = 0; i < (int)n; i++)#pragma warning (disable:4018)using namespace std;typedef long long int lint;typedef struct {int x;int y;}coordinate;//***** Main Program *****//最大公約数を求めるint hoge1(string S, int p) {int ret = 1;for (int i = 1; i <= min(p, (int)S.length() - p - 1); i++) {if (S[p + i] == S[p - i]) ret+=2;else break;}if (ret == S.length()) ret -= 2;return ret;}int hoge2(string S, int p) {int ret = 0;for (int i = 0; i <= min(p, (int)S.length() - p - 2); i++) {if (S[p - i] == S[p + 1 + i]) ret += 2;else break;}if (ret == S.length()) ret -= 2;return ret;}int main() {string S;cin >> S;int ret = 0;Loop(i, S.length()) ret = max(ret, hoge1(S, i));Loop(i, S.length() - 1) ret = max(ret, hoge2(S, i));cout << ret << endl;return 0;}