{"id":196,"date":"2011-08-24T12:37:25","date_gmt":"2011-08-24T04:37:25","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=196"},"modified":"2020-06-04T12:38:07","modified_gmt":"2020-06-04T04:38:07","slug":"poj-3620-avoid-the-lakes","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=196","title":{"rendered":"poj 3620 Avoid The Lakes"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/*\nDFS\n\u5bfb\u627e\u8fde\u5728\u4e00\u5757\u7684\u6700\u5927\u7684lake\u7684\u9762\u79ef \n\u7b80\u5355\u9898 \n*\/\n#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;cmath>\n#include&lt;cstring>\n#include&lt;cstdlib>\n#include&lt;cctype>\n#include&lt;iomanip>\n#include&lt;string>\n#include&lt;algorithm>\n#include&lt;ctime>\n#include&lt;stack>\n#include&lt;queue>\n#include&lt;vector>\n#define N 105\nusing namespace std;\nint m,n,ans,d;\nint map&#91;N]&#91;N],dir&#91;4]&#91;2]={1,0,-1,0,0,1,0,-1};\nbool legal(int x,int y)\n{if(x>=1&amp;&amp;x&lt;=m&amp;&amp;y>=1&amp;&amp;y&lt;=n) return true;return false;}\nvoid DFS(int x,int y)\n{\n\tint i,sx,sy;\n\tmap&#91;x]&#91;y]=1;\n\td++;\n\tfor(i=0;i&lt;4;i++)\n\t{\n\t\tsx=x+dir&#91;i]&#91;0];sy=y+dir&#91;i]&#91;1];\n\t\tif(legal(sx,sy)&amp;&amp;(!map&#91;sx]&#91;sy]))\n\t\t\tDFS(sx,sy);\n\t}\n\tif(d>ans) ans=d;\n}\nint main()\n{\n       int i,j,x,y,k;\n\t   while(cin>>m>>n>>k)\n\t\t{\n\t\t\tmemset(map,1,sizeof(map));\n\t\t\twhile(k--)\n\t\t\t{\n                  cin>>x>>y;\n                  map&#91;x]&#91;y]=0;         \n             }\n            ans=0;\n\t\t\tfor(i=1;i&lt;=m;i++)\n\t\t\t{\n\t\t\t\tfor(j=1;j&lt;=n;j++)\n\t\t\t\t{\n\t\t\t\t\tif(!map&#91;i]&#91;j])\n\t\t\t\t\t{\n\t\t\t\t\t\td=0;\n                        DFS(i,j);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tcout&lt;&lt;ans&lt;&lt;endl;\n\t\t}\n\t\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-196","post","type-post","status-publish","format-standard","hentry","category-06-01-acm"],"_links":{"self":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=196"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/196\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=196"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}