結果

問題 No.588 空白と回文
ユーザー mbanmban
提出日時 2018-01-18 22:03:38
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,021 bytes
コンパイル時間 2,124 ms
コンパイル使用メモリ 103,104 KB
実行使用メモリ 22,708 KB
最終ジャッジ日時 2023-08-25 23:27:27
合計ジャッジ時間 4,704 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
22,668 KB
testcase_01 AC 48 ms
20,656 KB
testcase_02 AC 45 ms
20,452 KB
testcase_03 WA -
testcase_04 AC 47 ms
20,536 KB
testcase_05 AC 46 ms
20,448 KB
testcase_06 AC 45 ms
18,388 KB
testcase_07 AC 47 ms
20,500 KB
testcase_08 AC 47 ms
22,560 KB
testcase_09 AC 47 ms
22,612 KB
testcase_10 AC 46 ms
20,592 KB
testcase_11 WA -
testcase_12 AC 48 ms
20,540 KB
testcase_13 AC 48 ms
20,624 KB
testcase_14 AC 49 ms
20,388 KB
testcase_15 AC 48 ms
22,596 KB
testcase_16 AC 47 ms
20,520 KB
testcase_17 AC 49 ms
20,440 KB
testcase_18 AC 46 ms
20,384 KB
testcase_19 AC 47 ms
22,492 KB
testcase_20 AC 48 ms
20,528 KB
testcase_21 AC 51 ms
20,536 KB
testcase_22 AC 49 ms
20,496 KB
testcase_23 WA -
testcase_24 AC 45 ms
20,448 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private string S;
        private void Scan()
        {
            var sc = new Scanner();
            S = sc.Next();
        }

        public void Solve()
        {
            Scan();
            int ans = 0;
            for (int i = 0; i < S.Length; i++)
            {
                ans = Math.Max(ans, Math.Max(Cnt(0, i), Cnt(i, S.Length - 1)));
            }
            Console.WriteLine(ans);
        }

        private int Cnt(int left, int right)
        {
            int res = 0;
            if((right-left)%2==0)
            {
                res++;
            }
            for (int i = 0; i < (right - left) / 2; i++)
            {
                if(S[left+i]==S[right-i])
                {
                    res += 2;
                }
            }
            return res;
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}
0