http://okajima.air-nifty.com/b/2010/01/post-abc6.html
人材獲得作戦・4 試験問題をやってみた
-----------------------------------------------------------
using System;using System.IO;using System.Collections.Generic;using System.Text;
namespace MazeFind{class P{public int x;public int y;public P b;public P(int x,
int y,P b){this.x=x;this.y=y;this.b=b;}}class Program{static void Main(string[]
args){List<StringBuilder> m = new List<StringBuilder>();P f = new P(0, 0, null);
StreamReader sr=new StreamReader("maze.txt");int i,j;for(i=0;!sr.EndOfStream;
i++){StringBuilder s=new StringBuilder(sr.ReadLine());m.Add(s);for (j=0;j<s.
Length;j++){if(s[j]=='S')f=new P(j,i,null);}}Queue<P> q = new Queue<P>();q.
Enqueue(f);while(q.Count > 0){P n=q.Dequeue();if (m[n.y][n.x]=='*'||m[n.y][n.x]
=='.')continue;else if(m[n.y][n.x]=='G'){P p=n.b;while(p!=null){m[p.y][p.x]='@'
;p=p.b;}break;}if(m[n.y-1][n.x]!='*'){q.Enqueue(new P(n.x, n.y-1,n));m[n.y][n.x]
='.';}if (m[n.y][n.x+1]!='*'){q.Enqueue(new P(n.x+1,n.y,n));m[n.y][n.x]='.';}if
(m[n.y+1][n.x]!= '*'){q.Enqueue(new P(n.x,n.y+1,n));m[n.y][n.x] = '.';}if(m[n.y]
[n.x-1] != '*'){q.Enqueue(new P(n.x-1,n.y,n));m[n.y][n.x] = '.';}}foreach
(StringBuilder s in m)Console.WriteLine(s.ToString().Replace('.', ' '));Console.
ReadLine();}}}
-----------------------------------------------------------
どうやってもこれ以上縮まらない