結果
問題 | No.340 雪の足跡 |
ユーザー | AreTrash |
提出日時 | 2016-04-23 19:01:36 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 652 ms / 1,000 ms |
コード長 | 3,171 bytes |
コンパイル時間 | 1,146 ms |
コンパイル使用メモリ | 107,292 KB |
実行使用メモリ | 49,700 KB |
最終ジャッジ日時 | 2024-04-15 04:19:55 |
合計ジャッジ時間 | 11,264 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
18,688 KB |
testcase_01 | AC | 30 ms
18,816 KB |
testcase_02 | AC | 28 ms
18,816 KB |
testcase_03 | AC | 30 ms
18,816 KB |
testcase_04 | AC | 30 ms
18,944 KB |
testcase_05 | AC | 28 ms
18,688 KB |
testcase_06 | AC | 30 ms
18,944 KB |
testcase_07 | AC | 30 ms
18,688 KB |
testcase_08 | AC | 30 ms
18,688 KB |
testcase_09 | AC | 31 ms
18,560 KB |
testcase_10 | AC | 30 ms
18,816 KB |
testcase_11 | AC | 38 ms
19,840 KB |
testcase_12 | AC | 36 ms
19,072 KB |
testcase_13 | AC | 37 ms
19,328 KB |
testcase_14 | AC | 59 ms
23,552 KB |
testcase_15 | AC | 65 ms
24,064 KB |
testcase_16 | AC | 55 ms
23,388 KB |
testcase_17 | AC | 73 ms
23,936 KB |
testcase_18 | AC | 65 ms
24,064 KB |
testcase_19 | AC | 72 ms
24,064 KB |
testcase_20 | AC | 454 ms
42,944 KB |
testcase_21 | AC | 349 ms
41,764 KB |
testcase_22 | AC | 48 ms
25,856 KB |
testcase_23 | AC | 519 ms
48,576 KB |
testcase_24 | AC | 452 ms
42,216 KB |
testcase_25 | AC | 452 ms
46,160 KB |
testcase_26 | AC | 103 ms
34,432 KB |
testcase_27 | AC | 45 ms
21,888 KB |
testcase_28 | AC | 90 ms
31,104 KB |
testcase_29 | AC | 531 ms
46,100 KB |
testcase_30 | AC | 336 ms
40,576 KB |
testcase_31 | AC | 564 ms
48,996 KB |
testcase_32 | AC | 652 ms
49,496 KB |
testcase_33 | AC | 450 ms
40,576 KB |
testcase_34 | AC | 631 ms
49,700 KB |
testcase_35 | AC | 520 ms
47,700 KB |
testcase_36 | AC | 526 ms
47,340 KB |
コンパイルメッセージ
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; namespace No340_2{ public class Program{ public static void Main(string[] args){ var input = Console.ReadLine().Split(' '); var w = int.Parse(input[0]); var h = int.Parse(input[1]); var n = int.Parse(input[2]); var imx = new int[h, w]; var imy = new int[w, h]; for(var i = 0; i < n; i++){ var m = int.Parse(Console.ReadLine()); var bn = Console.ReadLine().Split(' ').ToList().ConvertAll(int.Parse); for(var j = 1; j <= m; j++){ var from = Math.Min(bn[j - 1], bn[j]); var to = Math.Max(bn[j - 1], bn[j]); if(to - from < w){ var tmp = bn[j] / w; imx[tmp, from - tmp * w]++; imx[tmp, to - tmp * w]--; } else{ var tmp = bn[j] % w; imy[tmp, from / w]++; imy[tmp, to / w]--; } } } for(var i = 0; i < h; i++){ for(var j = 1; j < w; j++){ imx[i, j] += imx[i, j - 1]; } } for(var i = 0; i < w; i++){ for(var j = 1; j < h; j++){ imy[i, j] += imy[i, j - 1]; } } var result = new int[w * h]; result[0] = 1; var que = new Queue<int>(); if(imx[0, 0] != 0){ que.Enqueue(1); result[1] = 2; } if(imy[0, 0] != 0) { que.Enqueue(w); result[w] = 2; } while(que.Count > 0 && result[w * h - 1] == 0){ var cur = que.Dequeue(); { var tmp = cur / w; if(tmp == (cur - 1) / w && imx[tmp, cur - tmp * w - 1] != 0 && result[cur - 1] == 0){ que.Enqueue(cur - 1); result[cur - 1] = result[cur] + 1; } if(tmp == (cur + 1) / w && imx[tmp, cur - tmp * w] != 0 && result[cur + 1] == 0){ que.Enqueue(cur + 1); result[cur + 1] = result[cur] + 1; } } { var tmp = cur % w; if(cur - w > 0 && imy[tmp, cur / w - 1] != 0 && result[cur - w] == 0){ que.Enqueue(cur - w); result[cur - w] = result[cur] + 1; } if(cur + w < w * h && imy[tmp, cur / w] != 0 && result[cur + w] == 0){ que.Enqueue(cur + w); result[cur + w] = result[cur] + 1; } } } if(result[w * h - 1] == 0) Console.WriteLine("Odekakedekinai.."); else Console.WriteLine(result[w * h - 1] - 1); } } }