提出 #36052389


ソースコード 拡げる

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()
        {
            var N = 9;
            var G = new bool[N][];
            for (var i = 0; i < N; i++)
            {
                G[i] = Scanner.Scan<string>().Select(x => x == '#').ToArray();
            }

            var answer = 0;

            IEnumerable<(int H, int W)> F()
            {
                for (var i = 0; i < N; i++)
                {
                    for (var j = 0; j < N; j++)
                    {
                        yield return (i, j);
                    }
                }
            }

            foreach (var p1 in F())
            {
                foreach (var p2 in F())
                {
                    foreach (var p3 in F())
                    {
                        foreach (var p4 in F())
                        {
                            if (p1 == p2 || p1 == p3 || p1 == p4 || p2 == p3 || p2 == p4 || p3 == p4) continue;
                            var e1 = (p2.H - p1.H, p2.W - p1.W);
                            var e3 = (p4.H - p3.H, p4.W - p3.W);
                            var e2 = (p3.W - p1.W, -(p3.H - p1.H));
                            var ok = e1 == e3 && e1 == e2;
                            ok &= G[p1.H][p1.W];
                            ok &= G[p2.H][p2.W];
                            ok &= G[p3.H][p3.W];
                            ok &= G[p4.H][p4.W];
                            if (ok) answer++;
                        }
                    }
                }
            }

            answer /= 4;
            Console.WriteLine(answer);
        }

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

提出情報

提出日時
問題 C - Counting Squares
ユーザ AconCavy
言語 C# (.NET Core 3.1.201)
得点 300
コード長 4345 Byte
結果 AC
実行時間 1030 ms
メモリ 45252 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 15
セット名 テストケース
Sample 00_sample_01.txt, 00_sample_02.txt
All 00_sample_01.txt, 00_sample_02.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt
ケース名 結果 実行時間 メモリ
00_sample_01.txt AC 1024 ms 45244 KiB
00_sample_02.txt AC 1014 ms 45068 KiB
01_test_01.txt AC 1022 ms 45096 KiB
01_test_02.txt AC 1023 ms 44928 KiB
01_test_03.txt AC 1018 ms 45248 KiB
01_test_04.txt AC 1023 ms 45048 KiB
01_test_05.txt AC 1030 ms 45100 KiB
01_test_06.txt AC 1017 ms 45164 KiB
01_test_07.txt AC 1024 ms 45048 KiB
01_test_08.txt AC 1026 ms 45004 KiB
01_test_09.txt AC 1018 ms 45056 KiB
01_test_10.txt AC 1019 ms 45252 KiB
01_test_11.txt AC 1029 ms 45176 KiB
01_test_12.txt AC 1024 ms 45092 KiB
01_test_13.txt AC 1023 ms 44928 KiB