結果
問題 | No.323 yuki国 |
ユーザー | nokonoko |
提出日時 | 2017-09-30 20:22:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 412 ms / 5,000 ms |
コード長 | 3,768 bytes |
コンパイル時間 | 1,022 ms |
コンパイル使用メモリ | 111,360 KB |
実行使用メモリ | 53,760 KB |
最終ジャッジ日時 | 2024-06-28 12:40:38 |
合計ジャッジ時間 | 6,709 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
19,072 KB |
testcase_01 | AC | 31 ms
18,624 KB |
testcase_02 | AC | 31 ms
18,872 KB |
testcase_03 | AC | 31 ms
18,944 KB |
testcase_04 | AC | 32 ms
19,328 KB |
testcase_05 | AC | 33 ms
19,012 KB |
testcase_06 | AC | 32 ms
18,944 KB |
testcase_07 | AC | 30 ms
19,020 KB |
testcase_08 | AC | 370 ms
53,504 KB |
testcase_09 | AC | 185 ms
37,248 KB |
testcase_10 | AC | 30 ms
18,944 KB |
testcase_11 | AC | 30 ms
18,888 KB |
testcase_12 | AC | 30 ms
18,888 KB |
testcase_13 | AC | 179 ms
36,224 KB |
testcase_14 | AC | 379 ms
53,632 KB |
testcase_15 | AC | 155 ms
33,280 KB |
testcase_16 | AC | 346 ms
53,120 KB |
testcase_17 | AC | 180 ms
35,328 KB |
testcase_18 | AC | 32 ms
18,636 KB |
testcase_19 | AC | 252 ms
39,680 KB |
testcase_20 | AC | 34 ms
18,816 KB |
testcase_21 | AC | 412 ms
53,632 KB |
testcase_22 | AC | 75 ms
23,040 KB |
testcase_23 | AC | 412 ms
53,632 KB |
testcase_24 | AC | 44 ms
19,840 KB |
testcase_25 | AC | 179 ms
34,944 KB |
testcase_26 | AC | 44 ms
19,712 KB |
testcase_27 | AC | 393 ms
53,760 KB |
testcase_28 | AC | 189 ms
36,736 KB |
testcase_29 | AC | 195 ms
36,480 KB |
testcase_30 | AC | 29 ms
18,944 KB |
testcase_31 | AC | 30 ms
19,012 KB |
testcase_32 | AC | 31 ms
18,944 KB |
testcase_33 | AC | 31 ms
18,620 KB |
testcase_34 | AC | 31 ms
18,880 KB |
testcase_35 | AC | 30 ms
18,752 KB |
testcase_36 | AC | 31 ms
18,944 KB |
testcase_37 | AC | 29 ms
19,200 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.Linq; using System.Text; using System.Collections.Generic; using STR = System.String; using INT = System.Int32; using DEC = System.Double; class Program { public static IO IO = new IO(); public struct MEMODATA { public INT SIZE; public INT X; public INT Y; public MEMODATA(INT size, INT x, INT y) { SIZE = size; X = x; Y = y; } public bool SAME(MEMODATA t) { return SIZE == t.SIZE && X == t.X && Y == t.Y; } } static void Main(string[] args) { INT[] hw = IO.I(' '); INT[] a = IO.I(' '); INT[] b = IO.I(' '); STR[] s = IO.S(hw[0]); INT[] x = new INT[4] { -1, 0, 1, 0 }; INT[] y = new INT[4] { 0, 1, 0, -1 }; bool[,,] memo = new bool[100000, hw[0], hw[1]]; QUEUE<MEMODATA> q = new QUEUE<MEMODATA>(1001 * hw[0] * hw[1]); MEMODATA c = new MEMODATA(b[0], b[1], b[2]); Func<INT, INT, INT, bool> MEMOCHECK = (INT SIZE, INT X, INT Y) => { if (!memo[SIZE, X, Y]) { return memo[SIZE, X, Y] = true; } else { return false; } }; string o = "No"; MEMOCHECK(a[0], a[1], a[2]); q.PUSH(new MEMODATA(a[0], a[1], a[2])); long aaa = 0; while (q.SIZE() != 0) { MEMODATA data = q.POP(); if (data.SAME(c)) { o = "Yes"; break; } for (int i = 0; i < 4; i++) { INT nx = data.X + x[i]; INT ny = data.Y + y[i]; if (nx >= 0 && nx < hw[0] && ny >= 0 && ny < hw[1]) { INT nsize = data.SIZE + ((s[nx][ny] == '*') ? 1 : -1); if (nsize > 0 && nsize < 2500) { if (MEMOCHECK(nsize, nx, ny)) { q.PUSH(new MEMODATA(nsize, nx, ny)); } } } } aaa++; } IO.W(o); IO.F(); } } public class QUEUE<T> { protected INT m; private INT s, e, c; private T[] q; public QUEUE(INT max) { m = max; q = new T[m]; CLEAR(); } public void CLEAR() { e = 0; s = 0; c = 0; } public INT SIZE() { return c; } public T TOP() { return q[s]; } public T POP() { T r = q[s++]; s %= m; c--; return r; } public virtual void PUSH(T v) { q[e++] = v; e %= m; c++; } public bool EMPTY() { return SIZE() == 0; } } public class IO { private const int WMAX = 1000; private StringBuilder SB = new StringBuilder(); private T R<T>(Func<STR, T> f) { return f(Console.ReadLine()); } private T[] R<T>(Func<STR, T> f, char c) { return S().Split(c).Select(f).ToArray(); } private T[] R<T>(Func<STR, T> f, INT l) { T[] r = new T[l]; for (INT i = 0; i < l; i++) { r[i] = R(f); } return r; } private T[][] R<T>(Func<STR, T> f, INT l, char c) { T[][] r = new T[l][]; for (INT i = 0; i < l; i++) { r[i] = R<T>(f, c); } return r; } private void W<T>(Func<T, STR> f, T v, bool lf = true) { SB.Append(f(v)); if (lf) { SB.Append('\n'); } if (SB.Length >= WMAX) { F(); } } public STR S() { return R(s => s); } public STR[] S(char c) { return R(s => s, c); } public STR[] S(INT l) { return R(s => s, l); } public STR[][] S(INT l, char c) { return R(s => s, l, c); } public INT I() { return R(INT.Parse); } public INT[] I(char c) { return R(INT.Parse, c); } public INT[] I(INT l) { return R(INT.Parse, l); } public INT[][] I(INT l, char c) { return R(INT.Parse, l, c); } public DEC D() { return R(DEC.Parse); } public DEC[] D(char c) { return R(DEC.Parse, c); } public DEC[] D(INT l) { return R(DEC.Parse, l); } public DEC[][] D(INT l, char c) { return R(DEC.Parse, l, c); } public void W(object s, bool lf = true) { W(v => v.ToString(), s, lf); } public void F() { Console.Write(SB); SB.Length = 0; } }