{"id":102,"date":"2011-08-02T22:58:13","date_gmt":"2011-08-02T14:58:13","guid":{"rendered":"http:\/\/wangkaixuan.tech\/?p=102"},"modified":"2020-06-03T22:58:56","modified_gmt":"2020-06-03T14:58:56","slug":"uvaoj-457-linear-cellular-automata","status":"publish","type":"post","link":"http:\/\/www.wangkaixuan.tech\/?p=102","title":{"rendered":"uvaoj 457 &#8211; Linear Cellular Automata"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\/*\n\u9898\u610f\u7a0d\u96be\u61c2\n\u82f1\u8bed\u6c34\u5e73\u6709\u9650\u6240\u81f4\u3002\u3002\u3002\nzoj\u4e0a\u4e5f\u6709\u4e00\u9053\u7c7b\u4f3c\u7684\u9898\n\u4e0d\u8fc7\u6bd4\u8fd9\u4e2a\u96be\u5f97\u591a\nWR\u4e86N\u6b21 \n*\/\n#define LOCAL\n#include&lt;iostream>\n#include&lt;cstring>    \/\/memset()\u539f\u6765\u5305\u542b\u5728string.h\uff0c\u4e00\u76f4CE\u3002\u3002\u3002 \nusing namespace std;\nint main()\n{\n#ifdef LOCAL\n       freopen(\"input.txt\",\"r\",stdin);\n       freopen(\"output.txt\",\"w\",stdout);\n#endif\n    \n    \n    int n,DNA&#91;10],dish&#91;40],last&#91;40],i,j,first=1;\n    cin>>n;\n    while(n--)\n    {\n          cin.get();\n          if(!first)\n               cout&lt;&lt;endl;\n          else\n              first=0;\n          for(i=0;i&lt;10;i++)\n                cin>>DNA&#91;i];\n          memset(last,0,sizeof(last));\n          last&#91;19]=1;\n          for(j=0;j&lt;50;j++)\n          {\n                 for(i=0;i&lt;40;i++)\n                    dish&#91;i]=DNA&#91;((i-1)>=0?last&#91;i-1]:0)+last&#91;i]+((i+1)&lt;40?last&#91;i+1]:0)];\/\/\u8fd9\u4e2a\u53ef\u4ee5\u5f53\u505a\u4e07\u7528\u516c\u5f0f \n                 for(i=0;i&lt;40;i++)\n                 {\n                    switch(last&#91;i])\n                   {\n                      case 0:cout&lt;&lt;' ';break;\n                      case 1:cout&lt;&lt;'.';break;\n                      case 2:cout&lt;&lt;'x';break;\n                      case 3:cout&lt;&lt;'W';break;               \n                   }                 \n                  }   \n                  cout&lt;&lt;endl;\n                  for(i=0;i&lt;40;i++)\n                       last&#91;i]=dish&#91;i];                     \n          }   \n    }\n    return 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-102","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\/102","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=102"}],"version-history":[{"count":0,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wangkaixuan.tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}