結果

問題 No.2535 多重同値
ユーザー volhalinkvolhalink
提出日時 2023-11-11 04:11:39
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 229 ms / 2,000 ms
コード長 1,171 bytes
コンパイル時間 19,001 ms
コンパイル使用メモリ 158,736 KB
実行使用メモリ 182,320 KB
最終ジャッジ日時 2023-11-11 04:12:03
合計ジャッジ時間 10,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
30,884 KB
testcase_01 AC 59 ms
30,884 KB
testcase_02 AC 59 ms
30,884 KB
testcase_03 AC 59 ms
30,884 KB
testcase_04 AC 59 ms
30,884 KB
testcase_05 AC 59 ms
30,884 KB
testcase_06 AC 59 ms
30,884 KB
testcase_07 AC 59 ms
30,884 KB
testcase_08 AC 60 ms
30,884 KB
testcase_09 AC 60 ms
30,884 KB
testcase_10 AC 61 ms
30,884 KB
testcase_11 AC 59 ms
30,884 KB
testcase_12 AC 59 ms
30,884 KB
testcase_13 AC 59 ms
30,884 KB
testcase_14 AC 60 ms
30,884 KB
testcase_15 AC 61 ms
30,884 KB
testcase_16 AC 85 ms
31,652 KB
testcase_17 AC 229 ms
34,596 KB
testcase_18 AC 228 ms
34,596 KB
testcase_19 AC 227 ms
182,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (127 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var p = new bool[n];
        var r = new bool[n];
        var tr = -1;
        var cont = true;
        var input = Console.ReadLine();
        if (input == "Yes")
        {
            p[0] = true;
            tr = 0;
        }
        else
        {
            cont = false;
            p[0] = false;
        }
        for (int i = 1; i < n; i++)
        {
            input = Console.ReadLine();
            if (input == "Yes")
            {
                p[i] = true;
                if (cont) tr = i;
            }
            else
            {
                cont = false;
                p[i] = false;
            }
        }

        
        for(int i = n - 1; i > 0; i--)
        {
            r[i] = (p[i - 1] == p[i]) == p[i - 1];
        }
        r[0] = p[0];
        for (int i = 1; i < n; i++)
        {
            if (r[i]) r[i] = r[i - 1];
            else r[i] = !r[i - 1];
        }

        for (int i = 0; i < n; i++)
        {
            if (r[0] == p[0]) Console.WriteLine(r[i] ? "Yes" : "No");
        }
    }
}
0