結果
問題 | No.273 回文分解 |
ユーザー |
![]() |
提出日時 | 2020-09-11 15:18:16 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 1,330 bytes |
コンパイル時間 | 2,471 ms |
コンパイル使用メモリ | 103,424 KB |
実行使用メモリ | 17,664 KB |
最終ジャッジ日時 | 2024-12-26 01:08:20 |
合計ジャッジ時間 | 3,851 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using static System.Math;using System;public class Hello{static void Main(){var s = Console.ReadLine().Trim();getAns(s);}static int check2(string s, int p){var sL = s.Length;var d = 0;var count = 0;while (true){if (p + d + 1 == sL | p - d < 0) break;if (s[p - d] == s[p + d + 1]){count += 2;if (count == sL) { count -= 2; break; }}else break;d++;}return count;}static int check1(string s, int p){var sL = s.Length;var d = 1;var count = 1;while (true){if (p + d == sL | p - d < 0) break;if (s[p + d] == s[p - d]){count += 2;if (count == sL) { count -= 2; break; }}else break;d++;}return count;}static void getAns(string s){var sL = s.Length;var ans = 1;for (int i = 0; i < sL; i++){var t0 = check1(s, i);var t1 = check2(s, i);ans = Max(ans, t0);ans = Max(ans, t1);}Console.WriteLine(ans);}}