結果

問題 No.2307 [Cherry 5 th Tune *] Cool 46
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-02 23:17:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 362 ms / 2,000 ms
コード長 2,347 bytes
コンパイル時間 1,268 ms
コンパイル使用メモリ 115,972 KB
実行使用メモリ 63,652 KB
最終ジャッジ日時 2024-04-20 23:13:27
合計ジャッジ時間 32,586 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
26,048 KB
testcase_01 AC 32 ms
26,188 KB
testcase_02 AC 160 ms
44,812 KB
testcase_03 AC 171 ms
51,212 KB
testcase_04 AC 169 ms
49,244 KB
testcase_05 AC 175 ms
48,556 KB
testcase_06 AC 168 ms
49,192 KB
testcase_07 AC 155 ms
50,584 KB
testcase_08 AC 174 ms
50,828 KB
testcase_09 AC 171 ms
54,024 KB
testcase_10 AC 160 ms
52,336 KB
testcase_11 AC 198 ms
56,668 KB
testcase_12 AC 161 ms
50,352 KB
testcase_13 AC 222 ms
56,116 KB
testcase_14 AC 170 ms
52,924 KB
testcase_15 AC 162 ms
52,708 KB
testcase_16 AC 198 ms
56,892 KB
testcase_17 AC 173 ms
55,516 KB
testcase_18 AC 207 ms
59,976 KB
testcase_19 AC 228 ms
58,284 KB
testcase_20 AC 216 ms
60,300 KB
testcase_21 AC 235 ms
58,536 KB
testcase_22 AC 208 ms
55,316 KB
testcase_23 AC 218 ms
60,568 KB
testcase_24 AC 221 ms
57,440 KB
testcase_25 AC 219 ms
59,992 KB
testcase_26 AC 215 ms
63,652 KB
testcase_27 AC 221 ms
59,476 KB
testcase_28 AC 217 ms
57,528 KB
testcase_29 AC 223 ms
56,932 KB
testcase_30 AC 228 ms
61,896 KB
testcase_31 AC 227 ms
60,156 KB
testcase_32 AC 229 ms
60,080 KB
testcase_33 AC 208 ms
59,696 KB
testcase_34 AC 218 ms
61,152 KB
testcase_35 AC 230 ms
61,076 KB
testcase_36 AC 228 ms
61,428 KB
testcase_37 AC 214 ms
56,508 KB
testcase_38 AC 243 ms
47,932 KB
testcase_39 AC 362 ms
52,172 KB
testcase_40 AC 188 ms
57,376 KB
testcase_41 AC 207 ms
55,528 KB
testcase_42 AC 231 ms
57,740 KB
testcase_43 AC 227 ms
59,648 KB
testcase_44 AC 215 ms
60,500 KB
testcase_45 AC 220 ms
61,016 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 static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new List<string>();
        for (var u = 0; u < t; ++u)
        {
            var c = NList;
            var (n, m) = (c[0], c[1]);
            var a = new int[n];
            var b = new int[n];
            if (n > 0) a = NList;
            else ReadLine();
            if (m > 0) b = NList;
            else ReadLine();
            var bset = new HashSet<int>(b);
            var eq = new HashSet<int>();
            foreach (var ai in a) if (bset.Contains(ai)) eq.Add(ai);
            if (n == 0)
            {
                ans.Add("Yes");
                foreach (var bi in b) ans.Add("Blue " + bi);
            }
            else if (m == 0)
            {
                ans.Add("Yes");
                foreach (var ai in a) ans.Add("Red " + ai);
            }
            else if (eq.Count == 0)
            {
                ans.Add("No");
            }
            else
            {
                ans.Add("Yes");
                foreach (var ai in a) if (!eq.Contains(ai)) ans.Add("Red " + ai);
                var tmp = 0;
                foreach (var ai in eq)
                {
                    if (tmp % 2 == 0)
                    {
                        ans.Add("Red " + ai);
                        ans.Add("Blue " + ai);
                    }
                    else
                    {
                        ans.Add("Blue " + ai);
                        ans.Add("Red " + ai);
                    }
                    if (tmp == 0)
                    {
                        foreach (var bi in b) if (!eq.Contains(bi)) ans.Add("Blue " + bi);
                    }
                    ++tmp;
                }
            }
        }
        WriteLine(string.Join("\n", ans));
    }
}
0