結果

問題 No.640 76本のトロンボーン
ユーザー バカらっくバカらっく
提出日時 2018-01-28 00:32:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,889 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 108,084 KB
実行使用メモリ 23,792 KB
最終ジャッジ日時 2023-10-12 11:13:12
合計ジャッジ時間 4,920 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,732 KB
testcase_01 WA -
testcase_02 AC 65 ms
21,776 KB
testcase_03 WA -
testcase_04 AC 63 ms
21,776 KB
testcase_05 AC 64 ms
23,700 KB
testcase_06 AC 69 ms
21,864 KB
testcase_07 AC 69 ms
23,792 KB
testcase_08 AC 66 ms
21,716 KB
testcase_09 AC 66 ms
19,684 KB
testcase_10 AC 68 ms
23,780 KB
testcase_11 AC 65 ms
21,812 KB
testcase_12 AC 66 ms
21,804 KB
testcase_13 AC 65 ms
23,676 KB
testcase_14 AC 65 ms
21,732 KB
testcase_15 AC 63 ms
21,668 KB
testcase_16 AC 63 ms
23,688 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 System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        this.N = int.Parse(Reader.ReadLine());
        bool[][] map = new bool[this.N][];
        for (int i = 0; i < this.N; i++) {
            map[i] = Reader.ReadLine().Select(a => a == '.').ToArray();
        }

        int ans = GetAns(map);

        bool[][] tateyoko = new bool[this.N][];
        for (int i = 0; i < this.N; i++) {
            tateyoko[i] = new bool[this.N];
            for (int j = 0; j < this.N; j++) {
                tateyoko[i][j] = map[j][i];
            }
        }
        ans = Math.Max(ans, GetAns(tateyoko));

        bool gaisyu = true;
        for (int i = 0; i < this.N; i++) {
            if(!map[i][0]) {
                gaisyu = false;
                break;
            }
            if(!map[i].Last()) {
                gaisyu = false;
                break;
            }
            if(!map[0][i]) {
                gaisyu = false;
                break;
            }
            if(!map.Last()[i]) {
                gaisyu = false;
                break;
            }
        }
        if(gaisyu) {
            ans = Math.Max(ans, 4);
        }
        Console.WriteLine(ans);
    }

    private int GetAns(bool[][] map) {
        int ans = 0;

        int cnt = 0;
        for (int i = 0; i < this.N; i++) {
            if(map[i].Take(this.N-1).All(a=>a)) {
                cnt++;
            }
        }
        if(map.Select(a=>a.Last()).All(a=>a)) {
            cnt++;
        }
        ans = Math.Max(ans, cnt);
        cnt = 0;
        for (int i = 0; i < this.N; i++) {
            if(map[i].Skip(1).All(a=>a)) {
                cnt++;
            }
        }
        if(map.Select(a=>a.First()).All(a=>a)) {
            cnt++;
        }
        ans = Math.Max(ans, cnt);
        cnt = 0;
        for (int i = 0; i < this.N; i++) {
            if(map[i].Take(this.N-1).All(a=>a)||map[i].Skip(1).All(a=>a)) {
                cnt++;
            }
        }
        ans = Math.Max(ans, cnt);
        return ans;
    }


    private int N;

    public class Reader
    {
        private static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"



5
...#.
..#.#
.....
#....
##..#





";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0