結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
![]() |
提出日時 | 2018-06-09 17:28:38 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,727 bytes |
コンパイル時間 | 4,697 ms |
コンパイル使用メモリ | 114,548 KB |
実行使用メモリ | 382,460 KB |
最終ジャッジ日時 | 2024-11-25 12:30:23 |
合計ジャッジ時間 | 17,603 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 MLE * 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.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ichimatu { class Program { static char[,] map = new char[3000, 3000]; static int gyouMax; static int retuMax; static void Main(string[] args) { var input = Console.ReadLine(); var d = input.Split(' '); gyouMax = Int32.Parse(d[0]); retuMax = Int32.Parse(d[1]); var input2list = new List<string>(); for (int i = 0; i < gyouMax; i++) { input2list.Add(Console.ReadLine()); } for (int i = 0; i < gyouMax; i++) { var dd = input2list[i].Split(' '); for (int j = 0; j < retuMax; j++) { map[i, j] = char.Parse(dd[j]); } } var total = 0; for (int i = 0; i < gyouMax; i++) { for (int j = 0; j < retuMax; j++) { // 「1」を見つける if (map[i, j] == '1') { // 周辺探索 exec周辺探索(i, j); total += 1; } } } Console.WriteLine(total); } private static void exec周辺探索(int gyou, int retu) { //var tansaku_gyouList = new List<int>(); //var tansaku_retuList = new List<int>(); // 見つけた場所を探索済みにする map[gyou, retu] = '9'; // 探索対象をキューに入れる // 右をチェックする if (retu + 1 < retuMax) { if (map[gyou, retu + 1] == '1') { exec周辺探索(gyou, retu + 1); } } // 上をチェックする if (0 <= gyou - 1) { if (map[gyou - 1, retu] == '1') { exec周辺探索(gyou - 1, retu); } } // 下をチェックする if (gyou + 1 < gyouMax) { if (map[gyou + 1, retu] == '1') { exec周辺探索(gyou + 1, retu); } } // 左をチェックする if (0 <= retu - 1) { if (map[gyou, retu - 1] == '1') { exec周辺探索(gyou, retu - 1); } } } } }