結果
| 問題 |
No.640 76本のトロンボーン
|
| コンテスト | |
| ユーザー |
バカらっく
|
| 提出日時 | 2018-01-28 00:32:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,889 bytes |
| コンパイル時間 | 2,698 ms |
| コンパイル使用メモリ | 110,308 KB |
| 実行使用メモリ | 27,244 KB |
| 最終ジャッジ日時 | 2024-09-14 10:05:53 |
| 合計ジャッジ時間 | 2,492 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 13 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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();
}
}
バカらっく