結果
問題 |
No.588 空白と回文
|
ユーザー |
|
提出日時 | 2017-11-14 18:28:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,447 bytes |
コンパイル時間 | 881 ms |
コンパイル使用メモリ | 109,612 KB |
実行使用メモリ | 27,708 KB |
最終ジャッジ日時 | 2024-11-25 02:09:45 |
合計ジャッジ時間 | 2,328 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SpaceEscape { class Program { static void Main(string[] args) { string target = Console.ReadLine(); Console.WriteLine(checkAnagram(target)); } static int checkAnagram(string str) { int max_count = 0; // max count for anagram word for (int i = 0; i < str.Length; i++) { int count = 0; // count for anagram word for (int j = 1; j < str.Length; j++) { if (str.Length % 2 == 1) { if (i + j >= str.Length || i - j < 0) break; if (str[i + j] == str[i - j]) count++; } else { if (i + j >= str.Length || i - j - 1 < 0) break; if (str[i - j - 1] == str[i + j]) count++; } } if (max_count < count) max_count = count; } if (str.Length % 2 == 1) return max_count * 2 + 1; else return max_count * 2 + 2; } } }