<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -5,6 +5,7 @@
 
 #ifdef DEBUG
 #include &lt;fstream&gt;
+#include &lt;cassert&gt;
 using std::ifstream;
 using std::ofstream;
 ifstream fin(&quot;1107.in&quot;);
@@ -34,24 +35,34 @@ void input() {
         for (int j=1;j&lt;=R;++j) {
             char temp;
             cin.get(temp);
+            if ('\n'==temp)
+                cin.get(temp);
             if ('.'==temp)
                 map[i][j]=true;
         }
+#ifdef DEBUG
+    for (int i=1;i&lt;=C;++i) {
+        for (int j=1;j&lt;=R;++j)
+            cout&lt;&lt;map[i][j];
+        cout&lt;&lt;endl;
+    }
+#endif
 }
 
 void DFS(int x,int y,int depth) {
     visited[x][y]=true;
-    startx=x;
-    starty=y;
-    if (depth&gt;maxDep)
-        maxDep=depth;
-    if (x+1&lt;=C&amp;&amp;map[x+1][y]&amp;&amp;visited[x][y])
-        DFS(x+1,y,depth+1);
-    if (y+1&lt;=R&amp;&amp;map[x][y+1]&amp;&amp;visited[x][y])
+   if (depth&gt;maxDep) {
+       maxDep=depth;
+       startx=x;
+       starty=y;
+   }
+   if (x+1&lt;=C&amp;&amp;map[x+1][y]&amp;&amp;!visited[x+1][y])
+       DFS(x+1,y,depth+1);
+   if (y+1&lt;=R&amp;&amp;map[x][y+1]&amp;&amp;!visited[x][y+1])
         DFS(x,y+1,depth+1);
-    if (x-1&gt;=1&amp;&amp;map[x-1][y]&amp;&amp;visited[x][y])
+    if (x-1&gt;=1&amp;&amp;map[x-1][y]&amp;&amp;!visited[x-1][y])
         DFS(x-1,y,depth+1);
-    if (y-1&gt;=1&amp;&amp;map[x][y-1]&amp;&amp;visited[x][y])
+    if (y-1&gt;=1&amp;&amp;map[x][y-1]&amp;&amp;!visited[x][y-1])
         DFS(x,y-1,depth+1);
 }
 
@@ -63,17 +74,20 @@ int main() {
     for (i=1;i&lt;=C;++i)
         for (j=1;j&lt;=R;++j)
             if (map[i][j]) {
-                flag=true;
-                break;
+                DFS(i,j,0);
+                maxDep=0;
+                memset(visited,0,sizeof(bool)*(max+1)*(max+1));
+#ifdef DEBUG
+                cout&lt;&lt;startx&lt;&lt;','&lt;&lt;starty&lt;&lt;endl;
+#endif
+                DFS(startx,starty,0);
+#ifdef DEBUG
+                cout&lt;&lt;startx&lt;&lt;','&lt;&lt;starty&lt;&lt;endl;
+#endif
+ 
+                cout&lt;&lt;maxDep&lt;&lt;endl;
+                return 0;
             }
-    if (!flag) {
-        cout&lt;&lt;0&lt;&lt;endl;
-        return 0;
-    }
-    DFS(i,j,0);
-    maxDep=0;
-    memset(visited,0,sizeof(bool)*(max+1)*(max+1));
-    DFS(startx,starty,0);
-    cout&lt;&lt;maxDep&lt;&lt;endl;
+    cout&lt;&lt;0&lt;&lt;endl;
     return 0;
 }</diff>
      <filename>1107/1107.cpp</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,10 @@
-3 3
-###
-#.#
-###
-
+9 12
+#####...####
+#...#..##..#
+###.#..##..#
+..........##
+########.###
+#..........#
+#####..#####
+##....######
+#####.....##</diff>
      <filename>1107/1107.in</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cdb2a19ce7366199efcd05ca9c577d508b2e812c</id>
    </parent>
  </parents>
  <author>
    <name>leafduo</name>
    <email>leafduo@gmail.com</email>
  </author>
  <url>http://github.com/leafduo/vijos/commit/e863a68058be2fc023d70b5577a139912e4cda14</url>
  <id>e863a68058be2fc023d70b5577a139912e4cda14</id>
  <committed-date>2008-10-20T07:47:32-07:00</committed-date>
  <authored-date>2008-10-20T07:47:32-07:00</authored-date>
  <message>1107 AC</message>
  <tree>73a391bdd28fdb50d9f11305d8893c313fb888cb</tree>
  <committer>
    <name>leafduo</name>
    <email>leafduo@gmail.com</email>
  </committer>
</commit>
