結果
| 問題 | No.640 76本のトロンボーン |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-10-28 23:59:33 |
| 言語 | C# (.NET 10.0.402 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 45 ms / 2,000 ms |
| + 240µs | |
| コード長 | 3,000 bytes |
| 記録 | |
| コンパイル時間 | 10,486 ms |
| コンパイル使用メモリ | 171,148 KB |
| 実行使用メモリ | 33,024 KB |
| 最終ジャッジ日時 | 2026-10-28 23:59:47 |
| 合計ジャッジ時間 | 12,900 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge7_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (224 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
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();
static char[][] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine().ToCharArray()).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var n = NN;
var s = SList(n);
var ans = Count(0, n - 1, 0, n - 1, s);
if (CanPutHori(0, 0, s) && CanPutHori(n - 1, 1, s) && CanPutVert(1, 0, s) && CanPutVert(0, n - 1, s)) ans = Math.Max(ans, 4);
for (var i = 0; i < 4; ++i)
{
if (CanPutHori(0, 0, s) || CanPutHori(0, 1, s)) ans = Math.Max(ans, Count(1, n - 1, 0, n - 1, s) + 1);
if (((CanPutHori(0, 0, s) || CanPutHori(0, 1, s)) && CanPutVert(1, 0, s)) || (CanPutHori(0, 1, s) && (CanPutVert(0, 0, s) || CanPutVert(1, 0, s))))
ans = Math.Max(ans, Count(1, n - 1, 1, n - 1, s) + 2);
if (CanPutHori(0, 0, s) && CanPutVert(1, 0, s) && (CanPutVert(0, n - 1, s) || CanPutVert(1, n - 1, s))) ans = Math.Max(ans, 3);
if (CanPutHori(0, 1, s) && CanPutVert(1, n - 1, s) && (CanPutVert(0, 0, s) || CanPutVert(1, 0, s))) ans = Math.Max(ans, 3);
if (i + 1 < 4) s = Rotate(s);
}
WriteLine(ans);
}
static char[][] Rotate(char[][] s)
{
var ans = new char[s.Length][];
for (var i = 0; i < s.Length; ++i)
{
ans[i] = new char[s.Length];
for (var j = 0; j < s.Length; ++j) ans[i][j] = s[s.Length - j - 1][i];
}
return ans;
}
static int Count(int xs, int xe, int ys, int ye, char[][] s)
{
var ans = 0;
if (ye - ys >= s.Length - 2)
{
var sub = 0;
for (var i = xs; i <= xe; ++i)
{
if (ye - ys == s.Length - 1) if (CanPutHori(i, ys, s) || CanPutHori(i, ys + 1, s)) ++sub;
if (ye - ys == s.Length - 2) if (CanPutHori(i, ys, s)) ++sub;
}
ans = Math.Max(ans, sub);
}
if (xe - xs >= s.Length - 2)
{
var sub = 0;
for (var j = ys; j <= ye; ++j)
{
if (xe - xs == s.Length - 1) if (CanPutVert(xs, j, s) || CanPutVert(xs + 1, j, s)) ++sub;
if (xe - xs == s.Length - 2) if (CanPutVert(xs, j, s)) ++sub;
}
ans = Math.Max(ans, sub);
}
return ans;
}
static bool CanPutHori(int x, int y, char[][] s)
{
for (var j = 0; j < s.Length - 1; ++j) if (s[x][y + j] == '#') return false;
return true;
}
static bool CanPutVert(int x, int y, char[][] s)
{
for (var i = 0; i < s.Length - 1; ++i) if (s[x + i][y] == '#') return false;
return true;
}
}