結果

問題 No.3171 Color Restoration
ユーザー kakel-san
提出日時 2025-06-06 21:35:00
言語 C#
(.NET 8.0.404)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 2,164 bytes
コンパイル時間 8,417 ms
コンパイル使用メモリ 170,964 KB
実行使用メモリ 187,600 KB
最終ジャッジ日時 2025-06-06 21:35:13
合計ジャッジ時間 11,037 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

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();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var s = ReadLine().Split();
        var list1 = new List<string>() { "gray", "brown", "green", "cyan", "blue", "yellow", "orange", "red" };
        var list2 = new List<string>() { "gray", "green", "blue", "yellow", "red" };
        var list3 = new List<string>() { "gray", "green", "cyan", "blue", "violet", "orange", "red" };
        Array.Sort(s);
        var ans = 0;
        if (s[0] != s[1] && s[1] != s[2])
        {
            ans += Valid(s[0], s[1], s[2], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[0], s[2], s[1], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[1], s[0], s[2], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[1], s[2], s[0], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[2], s[0], s[1], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[2], s[1], s[0], list1, list2, list3) ? 1 : 0;
        }
        else if (s[0] == s[1] && s[1] == s[2])
        {
            ans += Valid(s[0], s[1], s[2], list1, list2, list3) ? 1 : 0;
        }
        else
        {
            ans += Valid(s[0], s[1], s[2], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[1], s[2], s[0], list1, list2, list3) ? 1 : 0;
            ans += Valid(s[2], s[0], s[1], list1, list2, list3) ? 1 : 0;
        }
        WriteLine(ans == 1 ? "Yes" : "No");
    }
    static bool Valid(string s1, string s2, string s3, List<string> list1, List<string> list2, List<string> list3)
    {
        return list1.Contains(s1) && list2.Contains(s2) && list3.Contains(s3);
    }
    static int ContainsCount(string s, List<string> list1, List<string> list2, List<string> list3)
    {
        var ans = list1.Contains(s) ? 1 : 0;
        ans += list2.Contains(s) ? 1 : 0;
        ans += list3.Contains(s) ? 1 : 0;
        return ans;
    }
}
0