{"id":59,"date":"2017-02-14T10:47:17","date_gmt":"2017-02-14T01:47:17","guid":{"rendered":"http:\/\/kpc2017.satoshis.jp\/?p=59"},"modified":"2021-09-23T17:27:41","modified_gmt":"2021-09-23T08:27:41","slug":"%e3%82%aa%e3%82%bb%e3%83%ad%e3%82%b2%e3%83%bc%e3%83%a0%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab","status":"publish","type":"post","link":"https:\/\/kpc2017.satoshis.jp\/?p=59","title":{"rendered":"\u30aa\u30bb\u30ed\u30b2\u30fc\u30e0\u306e\u30b5\u30f3\u30d7\u30eb"},"content":{"rendered":"<p>\u30aa\u30bb\u30ed\u30b2\u30fc\u30e0\u306e\u30b5\u30f3\u30d7\u30eb<br \/>\n<a href=\"http:\/\/tricky-code.net\/nicecode\/code42oseroai.php\">\u4eba\u9593 VS \u30b3\u30f3\u30d4\u30e5\u30fc\u30bf(AI)\u5bfe\u5c40 7\u884c\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 (C\u8a00\u8a9e)<\/a><\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n#include &lt;stdio.h&gt;\r\n\r\nint put, turn, all, done, pass, count, cur, i;\r\n\/\/ \u76e4\u72b6\u614b:\u6a2a9*\u7e2610\u3067\u3001\u4f7f\u7528\u306f8*8\r\n\/\/ 0:\u7121\u3057 1:1player 2:2player 3:\u6539\u884c\r\n\/\/ y*9+x\u3068\u3044\u3046\u30a4\u30e1\u30fc\u30b8\u30020\u884c\u76ee\u30689\u884c\u76ee\u306f\u756a\u5175\r\nint map[90] = {0};\r\n\/\/ \u76e4\u3092\u8d70\u67fb\u3059\u308b\u5834\u5408\u3001\u7e26\u6a2a\u659c\u3081\u65b9\u5411\u306b\u5411\u304b\u3046\u305f\u3081\u306b\u8db3\u3055\u308c\u308b\u3079\u304d\u6570\r\nint dir[] = { -10, -9, -8, -1, 1, 8, 9, 10 };\r\n\r\n\/\/ put\u306b\u99d2\u3092\u7f6e\u3044\u305f\u5834\u5408\u3072\u3063\u304f\u308a\u8fd4\u305b\u308b\u679a\u6570\u3092all\u306b\u8db3\u3059\r\nvoid check() \r\n{\r\n\tif (map[put] == 0) {\r\n\t\tfor (i = 0; i &lt; 8; i++) {\r\n\t\t\t\/\/ dir[i]\u306e\u65b9\u5411\u306e\u76f8\u624b\u306e\u30b3\u30de\u306e\u6570\u3092\u78ba\u8a8d\r\n\t\t\tfor (count = 0, cur = put+dir[i]; map[cur] == 3 - turn; cur += dir[i]) {\r\n\t\t\t\tcount++;\r\n\t\t\t}\r\n\t\t\tif (count &amp;&amp; map[cur] == turn) {\r\n\t\t\t\t\/\/ \uff11\u679a\u4ee5\u4e0a\u5b58\u5728\u3057\u3001\u305d\u306e\u4e0a\u7aef\u304c\u81ea\u5206\u306e\u30b3\u30de\u3060\u3063\u305f\u3089\r\n\t\t\t\tall += count;\r\n\t\t\t\tcur = put;\r\n\t\t\t\tif (done) {\r\n\t\t\t\t\t\/\/ done\u304ctrue\u306e\u5834\u5408\u306f\u3001\u5b9f\u969b\u306b\u3072\u3063\u304f\u308a\u8fd4\u3059\r\n\t\t\t\t\tdo {\r\n\t\t\t\t\t\tmap[cur] = turn, cur += dir[i];\r\n\t\t\t\t\t} while (map[cur] != turn);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n\r\n\/\/ map\u306b\u5bfe\u5fdc\u3059\u308b\u30aa\u30bb\u30ed\u99d2\uff06\u6539\u884c\r\nchar *h = &quot;\u30fb\u25cb\u25cf\\n&quot;;\r\n\r\nint main() {\r\n\t\/\/ \u521d\u671f\u5316\r\n\tfor (i = 1, map[41] = map[49] = 2; i &lt; 10; map[i++*9] = 3) {\r\n\t\tmap[40] = map[50] = turn = pass = 1;\r\n\t}\r\n\tfor (;; all = done = 0) { \/\/ \u30eb\u30fc\u30d7\u306e\u305f\u3073\u306ball\u3068done\u3092\u521d\u671f\u5316\uff08\u30bb\u30df\u30b3\u30ed\u30f3\u3092\uff11\u3064\u524a\u9664\u3059\u308b\u305f\u3081\uff09\r\n\t\t\/\/ \u76e4\u306e\u8868\u793a\u3002\u4eca\u56de\u306e\u30c7\u30fc\u30bf\u69cb\u9020\u3060\u3068\u3053\u308c\u3067\u8868\u793a\u3067\u304d\u308b\r\n\t\tfor (put = 9; put &lt; 82; ++put) {\r\n\t\t\tcheck();\r\n\t\t\tprintf(&quot;%.2s&quot;, &amp;h[map[put]*2]);\r\n\t\t}\r\n\t\tif (all) {\r\n\t\t\tfor (done = all = pass = put = 8; all == 8; check()) {\r\n\t\t\t\t\/\/ \u30b3\u30de\u3092\u7f6e\u304f\uff08\u4eba\u306f\u5165\u529b\u3057\u3001\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u306f\u5de6\u4e0a\u304b\u3089\u9806\u306b\uff09\r\n\t\t\t\tturn - 2 ? (scanf(&quot;%d %d&quot;, &amp;put, &amp;i), put+=i*9) : ++put;\r\n\t\t\t}\r\n\t\t} else if (pass) {\r\n\t\t\t\/\/ \u30b3\u30de\u3092\u7f6e\u3051\u306a\u3044\u306e\u3067\u30d1\u30b9\r\n\t\t\tpass = 0;\r\n\t\t\tprintf(&quot;pass&quot;);\r\n\t\t} else {\r\n\t\t\tbreak;\r\n\t\t}\r\n\t\t\/\/ \u4ea4\u4ee3\r\n\t\tturn = 3 - turn;\r\n\t}\r\n\treturn 0;\r\n}\r\n<\/pre>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>\u30aa\u30bb\u30ed\u30b2\u30fc\u30e0\u306e\u30b5\u30f3\u30d7\u30eb \u4eba\u9593 VS \u30b3\u30f3\u30d4\u30e5\u30fc\u30bf(AI)\u5bfe\u5c40 7\u884c\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0 (C\u8a00\u8a9e)<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/59"}],"collection":[{"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":3,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":62,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/62"}],"wp:attachment":[{"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kpc2017.satoshis.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}