提出 #1900493


ソースコード 拡げる

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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var len = s.Select(x=>0).ToArray();

            if(s.Length%2==0)
            {
                if (s[s.Length / 2 - 1] == s[s.Length / 2])
                {
                    var current = s.Length / 2 - 1;
                    int ans1 = 0;
                    for (int i = 1; ; i++)
                    {
                        if (current - i < 0 || s[current - i + 1] != s[current - i])
                        {
                            ans1 = s.Length / 2 + i;
                            break;
                        }
                    }
                    current = s.Length / 2;
                    int ans2 = 0;
                    for (int i = 1; ; i++)
                    {
                        if (current + i >= s.Length || s[current + i - 1] != s[current + i])
                        {
                            ans2 = s.Length / 2 + i;
                            break;
                        }
                    }
                    Console.WriteLine(Math.Min(ans1, ans2));
                }
                else
                {
                    Console.WriteLine(s.Length / 2);
                }
            }
            else
            {
                var current = s.Length / 2 ;
                int ans1 = 0;
                for (int i = 1; ; i++)
                {
                    if (current - i < 0 || s[current - i + 1] != s[current - i])
                    {
                        ans1 = s.Length / 2 + i ;
                        break;
                    }
                }
                current = s.Length / 2 ;
                int ans2 = 0;
                for (int i = 1; ; i++)
                {
                    if (current + i >= s.Length || s[current + i - 1] != s[current + i])
                    {
                        ans2 = s.Length / 2 + i;
                        break;
                    }
                }
                Console.WriteLine(Math.Min(ans1, ans2));
            }
            return;

        }
    }
}

提出情報

提出日時
問題 D - Wide Flip
ユーザ define0314
言語 C# (Mono 4.6.2.0)
得点 500
コード長 2346 Byte
結果 AC
実行時間 27 ms
メモリ 13336 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 30
セット名 テストケース
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, s1.txt, s2.txt, s3.txt
ケース名 結果 実行時間 メモリ
01.txt AC 27 ms 12896 KiB
02.txt AC 27 ms 12896 KiB
03.txt AC 27 ms 12896 KiB
04.txt AC 27 ms 13336 KiB
05.txt AC 27 ms 12896 KiB
06.txt AC 27 ms 12896 KiB
07.txt AC 27 ms 11288 KiB
08.txt AC 26 ms 10848 KiB
09.txt AC 26 ms 10848 KiB
10.txt AC 26 ms 12896 KiB
11.txt AC 26 ms 10848 KiB
12.txt AC 26 ms 10848 KiB
13.txt AC 26 ms 10848 KiB
14.txt AC 26 ms 10848 KiB
15.txt AC 27 ms 12896 KiB
16.txt AC 26 ms 10848 KiB
17.txt AC 27 ms 12896 KiB
18.txt AC 27 ms 12896 KiB
19.txt AC 26 ms 12896 KiB
20.txt AC 25 ms 10848 KiB
21.txt AC 22 ms 11220 KiB
22.txt AC 22 ms 9300 KiB
23.txt AC 22 ms 11220 KiB
24.txt AC 22 ms 11220 KiB
25.txt AC 22 ms 11220 KiB
26.txt AC 22 ms 11220 KiB
27.txt AC 23 ms 11348 KiB
s1.txt AC 23 ms 13268 KiB
s2.txt AC 23 ms 11220 KiB
s3.txt AC 22 ms 11220 KiB