AtCoder Regular Contest 069

Submission #1357610

Source codeソースコード

using System;

namespace arc069_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            bool[] animals = new bool[n + 1];
            animals[0] = true; animals[1] = true;
            for (int i = 2; i <= n; i++)
            {
                if ((s[(i - 1) % n] == 'o') == (animals[i - 1] == true)) animals[i] = animals[i - 2];
                else animals[i] = !animals[i - 2];
            }
            if (animals[0] == animals[n])
            {
                for (int i = 0; i < n; i++)
                {
                    Console.Write(animals[i] ? 'S' : 'W');
                }
                Console.WriteLine();
            }
            else
            {
                animals[0] = true; animals[1] = false;
                for (int i = 2; i <= n; i++)
                {
                    if ((s[(i - 1) % n] == 'o') == (animals[i - 1] == true)) animals[i] = animals[i - 2];
                    else animals[i] = !animals[i - 2];
                }
                if (animals[0] == animals[n])
                {
                    for (int i = 0; i < n; i++)
                    {
                        Console.Write(animals[i] ? 'S' : 'W');
                    }
                    Console.WriteLine();
                }
                else
                {
                    animals[0] = false; animals[1] = true;
                    for (int i = 2; i <= n; i++)
                    {
                        if ((s[(i - 1) % n] == 'o') == (animals[i - 1] == true)) animals[i] = animals[i - 2];
                        else animals[i] = !animals[i - 2];
                    }
                    if (animals[0] == animals[n])
                    {
                        for (int i = 0; i < n; i++)
                        {
                            Console.Write(animals[i] ? 'S' : 'W');
                        }
                        Console.WriteLine();
                    }
                    else
                    {
                        animals[0] = false; animals[1] = false;
                        for (int i = 2; i <= n; i++)
                        {
                            if ((s[(i - 1) % n] == 'o') == (animals[i - 1] == true)) animals[i] = animals[i - 2];
                            else animals[i] = !animals[i - 2];
                        }
                        if (animals[0] == animals[n])
                        {
                            for (int i = 0; i < n; i++)
                            {
                                Console.Write(animals[i] ? 'S' : 'W');
                            }
                            Console.WriteLine();
                        }
                        else
                        {
                            Console.WriteLine(-1);
                        }
                    }
                }
            }
        }
    }
}

Submission

Task問題 D - Menagerie
User nameユーザ名 ひゅ~Men
Created time投稿日時
Language言語 C# (Mono 4.6.2.0)
Status状態 WA
Score得点 0
Source lengthソースコード長 3064 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_example_01.txt,00_example_02.txt,00_example_03.txt
All 0 / 500 00_example_01.txt,00_example_02.txt,00_example_03.txt,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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_example_01.txt AC 20 ms 11092 KB
00_example_02.txt AC 20 ms 11092 KB
00_example_03.txt AC 20 ms 9044 KB
01.txt WA
02.txt AC 109 ms 13156 KB
03.txt AC 20 ms 11092 KB
04.txt AC 19 ms 9044 KB
05.txt WA
06.txt AC 196 ms 11360 KB
07.txt WA
08.txt AC 52 ms 9080 KB
09.txt AC 28 ms 11072 KB
10.txt WA
11.txt WA
12.txt WA
13.txt WA