{"id":646,"date":"2009-11-01T13:55:00","date_gmt":"2009-11-01T05:55:00","guid":{"rendered":"http:\/\/localhost\/?p=3"},"modified":"2009-11-01T13:55:00","modified_gmt":"2009-11-01T05:55:00","slug":"sgu_463","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/wjmzbmr\/?p=646","title":{"rendered":"sgu 463"},"content":{"rendered":"<p> \u597d\u6c34\u7684\u9898\u963f\u3002\u3002\u76f4\u63a5\u6a21\u62df\u5c31OK\u4e86\u3002\u3002\u4e0d\u8fc7\u4e5f\u6709\u4e00\u70b9\u9ebb\u70e6\u3002\u3002\u4e00\u6b21AC\u4e86\u3002\u3002<br \/>http:\/\/acm.sgu.ru\/problem.php?contest=0&amp;problem=463<br \/>#include&lt;iostream&gt;<br \/>#define REP(i,a,b) for(int i=a;i&lt;=b;i++)<br \/>using namespace std;<br \/>const int maxn=100+10;<br \/>const int di[]={-1,0,1,0},dj[]={0,1,0,-1};<br \/>int B[maxn][maxn]={0};<br \/>bool pass[maxn][maxn]={0};<br \/>int Pass(int x,int y)<br \/>{<br \/>int ans=B[x][y];<br \/>if(pass[x][y]) ans\/=2;<br \/>pass[x][y]=true;<br \/>return ans;<br \/>}<br \/>int value(int x,int y,int d)<br \/>{<br \/>int ans=0;<br \/>switch(d)<br \/>{<br \/>case 0:ans=Pass(x-1,y-1)+Pass(x-1,y);break;<br \/>case 1:ans=Pass(x-1,y)+Pass(x,y);break;<br \/>case 2:ans=Pass(x,y-1)+Pass(x,y);break;<br \/>case 3:ans=Pass(x-1,y-1)+Pass(x,y-1);break;<br \/>}<br \/>return ans;<br \/>}<br \/>int main()<br \/>{<br \/>int n,m;<br \/>cin&gt;&gt;n&gt;&gt;m;<br \/>REP(i,1,n)<br \/>REP(j,1,m)<br \/>{<br \/>char t;cin&gt;&gt;t;<br \/>B[i][j]=t-&#8216;0&#8217;;<br \/>}<br \/>int d=1,x=1,y=1,ans=0;<br \/>char t;<br \/>while(cin&gt;&gt;t)<br \/>{<br \/>switch(t)<br \/>{<br \/>case &#8216;M&#8217;:ans+=value(x,y,d);<br \/>x+=di[d],y+=dj[d];break;<br \/>case &#8216;L&#8217;:d&#8211;;if(d&lt;0) d=3;break;<br \/>case &#8216;R&#8217; :d++;if(d&gt;3) d=0;<br \/>}<br \/>}<br \/>cout&lt;&lt;ans&lt;&lt;endl;<br \/>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u597d\u6c34\u7684\u9898\u963f\u3002\u3002\u76f4\u63a5\u6a21\u62df\u5c31OK\u4e86\u3002\u3002\u4e0d\u8fc7\u4e5f\u6709\u4e00\u70b9\u9ebb\u70e6\u3002\u3002\u4e00\u6b21AC\u4e86\u3002\u3002http:\/\/acm.sgu.ru\/problem.php?contest=0&amp;problem=463#include&lt;iostream&gt;#define REP(i,a,b) for(int i=a;i&lt;=b;i++)using namespace std;const int maxn=100+10;const int di[]={-1,0,1,0},dj[]={0,1,0,-1};int B[maxn][maxn]={0};bool pass[maxn][maxn]={0};int Pass(int x,int y){int ans=B[x][y];if(pass[x][y]) ans\/=2;pass[x][y]=true;return ans;}int value(int x,int y,int d){int ans=0;switch(d){case 0:ans=Pass(x-1,y-1)+Pass(x-1,y);break;case 1:ans=Pass(x-1,y)+Pass(x,y);break;case 2:ans=Pass(x,y-1)+Pass(x,y);break;case 3:ans=Pass(x-1,y-1)+Pass(x,y-1);break;}return ans;}int main(){int n,m;cin&gt;&gt;n&gt;&gt;m;REP(i,1,n)REP(j,1,m){char t;cin&gt;&gt;t;B[i][j]=t-&#8216;0&#8217;;}int d=1,x=1,y=1,ans=0;char t;while(cin&gt;&gt;t){switch(t){case &#8216;M&#8217;:ans+=value(x,y,d);x+=di[d],y+=dj[d];break;case &#8216;L&#8217;:d&#8211;;if(d&lt;0) d=3;break;case &#8216;R&#8217; :d++;if(d&gt;3) d=0;}}cout&lt;&lt;ans&lt;&lt;endl;}<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[10],"tags":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/646"}],"collection":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=646"}],"version-history":[{"count":0,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=\/wp\/v2\/posts\/646\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/wjmzbmr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}