提出 #47225443


ソースコード 拡げる

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks;

public class C
{
    public static void Main()
    {
        using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static void Solve()
    {
        const int N = 9;
        var A = new int[N][];
        for (var i = 0; i < N; i++)
        {
            A[i] = Scanner.ScanEnumerable<int>().Select(x => x - 1).ToArray();
        }

        var answer = true;
        var mask = (1 << 9) - 1;

        for (var i = 0; i < N; i++)
        {
            var v = 0;
            for (var j = 0; j < N; j++)
            {
                v |= 1 << A[i][j];
            }

            answer &= v == mask;
        }

        for (var j = 0; j < N; j++)
        {
            var v = 0;
            for (var i = 0; i < N; i++)
            {
                v |= 1 << A[i][j];
            }

            answer &= v == mask;
        }

        for (var a = 0; a < 3; a++)
        {
            for (var b = 0; b < 3; b++)
            {
                var v = 0;
                for (var i = 0; i < 3; i++)
                {
                    for (var j = 0; j < 3; j++)
                    {
                        v |= 1 << A[a * 3 + i][b * 3 + j];
                    }
                }

                answer &= v == mask;
            }
        }

        Console.WriteLine(answer ? "Yes" : "No");
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]));
        }
        public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]));
        }
        public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]));
        }
        public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            var line = Console.ReadLine()?.Trim() ?? string.Empty;
            return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
        }
        private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
    }
}

提出情報

提出日時
問題 C - Number Place
ユーザ AconCavy
言語 C# 11.0 (.NET 7.0.7)
得点 250
コード長 3971 Byte
結果 AC
実行時間 62 ms
メモリ 26700 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 250 / 250
結果
AC × 3
AC × 31
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 53 ms 26544 KiB
example_01.txt AC 55 ms 26328 KiB
example_02.txt AC 58 ms 26276 KiB
hand_00.txt AC 51 ms 26344 KiB
hand_01.txt AC 48 ms 26700 KiB
hand_02.txt AC 58 ms 26316 KiB
random_00.txt AC 53 ms 26340 KiB
random_01.txt AC 58 ms 26544 KiB
random_02.txt AC 54 ms 26308 KiB
random_03.txt AC 47 ms 26316 KiB
random_04.txt AC 54 ms 26284 KiB
random_05.txt AC 49 ms 26336 KiB
random_06.txt AC 54 ms 26304 KiB
random_07.txt AC 48 ms 26164 KiB
random_08.txt AC 56 ms 26676 KiB
random_09.txt AC 55 ms 26228 KiB
random_10.txt AC 56 ms 26328 KiB
random_11.txt AC 49 ms 26240 KiB
random_12.txt AC 53 ms 26332 KiB
random_13.txt AC 62 ms 26364 KiB
random_14.txt AC 46 ms 26548 KiB
random_15.txt AC 53 ms 26552 KiB
random_16.txt AC 48 ms 26300 KiB
random_17.txt AC 53 ms 26324 KiB
random_18.txt AC 54 ms 26324 KiB
random_19.txt AC 56 ms 26320 KiB
random_20.txt AC 53 ms 26312 KiB
random_21.txt AC 45 ms 26328 KiB
random_22.txt AC 50 ms 26312 KiB
random_23.txt AC 50 ms 26676 KiB
random_24.txt AC 50 ms 26312 KiB