結果

問題 No.486 3 Straight Win(3連勝)
ユーザー funakoshi
提出日時 2019-06-28 11:49:16
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 103,680 KB
実行使用メモリ 17,408 KB
最終ジャッジ日時 2024-07-02 04:08:37
合計ジャッジ時間 2,466 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int west = 1;
            int east = 1;
            string before = input.Substring(0,1);
            bool win = false;
            for(int i=1;i<input.Length;i++)
            {
                string temp = input.Substring(i, 1);
                if(temp=="O")
                {
                    if (before == temp)
                    {
                        east++;
                        before = temp;
                    }
                    else
                    {
                        east = 1;
                        before = temp;
                    }

                    if (east == 3)
                    {
                        Console.WriteLine("East");
                        win = true;
                        break;
                    }
                    
                }
                else
                {
                    if (before == temp)
                    {
                        west++;
                        before = temp;
                    }
                    else
                    {
                        west = 1;
                        before = temp;
                    }
                    if (west == 3)
                    {
                        Console.WriteLine("West");
                        win = true;
                        break;
                    }
                }
            }
            if(win==false)
            {
                Console.WriteLine("NA");
            }
        }

    }
}
0