{"id":1196,"date":"2015-08-15T18:59:30","date_gmt":"2015-08-15T10:59:30","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=1196"},"modified":"2015-09-09T00:41:14","modified_gmt":"2015-09-08T16:41:14","slug":"2015-multi-university-training-contest-7-%ef%bc%8d-host-by-uestc","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/2015-multi-university-training-contest-7-%ef%bc%8d-host-by-uestc\/","title":{"rendered":"2015 Multi-University Training Contest 7 \uff0d Host by UESTC"},"content":{"rendered":"<h2>Problem F. Tetris<\/h2>\n<h3>Brief description: <\/h3>\n<p>\u6a21\u62df\u4fc4\u7f57\u65af\u65b9\u5757\u6e38\u620f\u3002<\/p>\n<h3>Analysis: <\/h3>\n<p>Dead-do<\/p>\n<pre class=\"brush: cpp; collapse: true; light: false; title: ; toolbar: true; notranslate\" title=\"\">\r\n\r\nconst int N = 12, M = 9;\r\n\r\nbool G&#x5B;20]&#x5B;20];\r\n\r\nbool inGrid(int x, int y){\r\n    return x &gt;= 0 &amp;&amp; y &gt;= 0 &amp;&amp; x &lt; N &amp;&amp; y &lt; M;\r\n}\r\n\r\n\r\nstruct T{\r\n    VVII p; int x, y, z;\r\n    void ww(){\r\n        int zz = z;\r\n        ++zz; if (zz == p.size()) zz = 0;\r\n        ECH(it, p&#x5B;zz]){\r\n            int xx = x + it-&gt;fi, yy = y + it-&gt;se;\r\n            if (!inGrid(xx, yy) || G&#x5B;xx]&#x5B;yy]) return;\r\n        }\r\n        z = zz;\r\n    }\r\n    void aa(){\r\n        \/\/if (y == 0) return;\r\n        --y; ECH(it, p&#x5B;z]){\r\n            int xx = x + it-&gt;fi, yy = y + it-&gt;se;\r\n            if (!inGrid(xx, yy) || G&#x5B;xx]&#x5B;yy]){\r\n                ++y;\r\n                return;\r\n            }\r\n        }\r\n    }\r\n    void dd(){\r\n        \/\/if (y != M-1) return;\r\n        ++y; ECH(it, p&#x5B;z]){\r\n            int xx = x + it-&gt;fi, yy = y + it-&gt;se;\r\n            if (!inGrid(xx, yy) || G&#x5B;xx]&#x5B;yy]){\r\n                --y;\r\n                return;\r\n            }\r\n        }\r\n    }\r\n    bool ss(){\r\n\r\n        \/\/cout &lt;&lt; &quot;!?&quot; &lt;&lt; endl;\r\n\r\n        ++x; ECH(it, p&#x5B;z]){\r\n            int xx = x + it-&gt;fi, yy = y + it-&gt;se;\r\n            if (!inGrid(xx, yy) || G&#x5B;xx]&#x5B;yy]){\r\n                --x;\r\n          \/\/      cout &lt;&lt; &quot;aaa&quot; &lt;&lt; endl;\r\n                return false;\r\n            }\r\n        }\r\n        \/\/cout &lt;&lt; &quot;aaa&quot; &lt;&lt; endl;\r\n        return true;\r\n    }\r\n    void go(char c){\r\n        if (c == 'w') ww();\r\n        else if (c == 'a') aa();\r\n        else if (c == 'd') dd();\r\n        else if (c == 's') ss();\r\n    }\r\n\r\n    int eli(){\r\n\r\n        \/\/cout &lt;&lt; &quot;1&quot; &lt;&lt; endl;\r\n        ECH(it, p&#x5B;z]){\r\n            int xx = x + it-&gt;fi, yy = y + it-&gt;se;\r\n            \/\/cout &lt;&lt; z &lt;&lt; &quot; &quot; &lt;&lt; it-&gt;fi &lt;&lt; &quot; &quot; &lt;&lt; it-&gt;se &lt;&lt; endl;\r\n            \/\/cout &lt;&lt; xx &lt;&lt; &quot; &quot; &lt;&lt; yy &lt;&lt; endl;\r\n            G&#x5B;xx]&#x5B;yy] = true;\r\n        }\r\n        \/\/cout &lt;&lt; &quot;2&quot; &lt;&lt; endl;\r\n        int z = 0; x = N-1; do{\r\n            int j; REP_N(j, M) if (!G&#x5B;x]&#x5B;j]) break;\r\n            if (j == M){\r\n                ++z; DWN_1(i, x, 1) REP(j, M) G&#x5B;i]&#x5B;j] = G&#x5B;i-1]&#x5B;j];\r\n                REP(j, M) G&#x5B;0]&#x5B;j] = 0;\r\n            }\r\n            else{\r\n                --x;\r\n            }\r\n        } while (x &gt;= 0);\r\n        \/\/cout &lt;&lt; &quot;3&quot; &lt;&lt; endl;\r\n        return z;\r\n    }\r\n\r\n    void init(int t){\r\n\r\n        x = 3, y = 3; z = 0; p.clear(); VII pp;\r\n\r\n        if (t == 0){\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(0, 1));\r\n            pp.PB(MP(-1, 0));\r\n            pp.PB(MP(-1, 1));\r\n            p.PB(pp);\r\n        }\r\n        else if (t == 1){\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(-1, 0));\r\n            pp.PB(MP(-2, 0));\r\n            pp.PB(MP(-3, 0));\r\n            p.PB(pp);\r\n            pp.clear();\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(0, 1));\r\n            pp.PB(MP(0, 2));\r\n            pp.PB(MP(0, 3));\r\n            p.PB(pp);\r\n        }\r\n        else{\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(-1, 0));\r\n            pp.PB(MP(0, 1));\r\n            pp.PB(MP(0, 2));\r\n            p.PB(pp);\r\n            pp.clear();\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(-1, 0));\r\n            pp.PB(MP(-2, 0));\r\n            pp.PB(MP(-2, 1));\r\n            p.PB(pp);\r\n            pp.clear();\r\n            pp.PB(MP(-1, 0));\r\n            pp.PB(MP(-1, 1));\r\n            pp.PB(MP(-1, 2));\r\n            pp.PB(MP(0, 2));\r\n            p.PB(pp);\r\n            pp.clear();\r\n            pp.PB(MP(0, 0));\r\n            pp.PB(MP(0, 1));\r\n            pp.PB(MP(-1, 1));\r\n            pp.PB(MP(-2, 1));\r\n            p.PB(pp);\r\n        }\r\n    }\r\n} T;\r\n\r\nchar cmd&#x5B;1009];\r\n\r\nint Run(){\r\n    RST(G); int n; RD(n); RS(cmd); int o = 0, s = 0; REP(i, n){\r\n            T.init(RD()); do{\r\n                if (!cmd&#x5B;o]) return s;\r\n                T.go(cmd&#x5B;o++]);\r\n            } while (T.ss());\r\n            s += T.eli();\r\n\r\n\r\n            \/*REP(i, N){\r\n                REP(j, M){\r\n\r\n                    bool bj = false;\r\n                    ECH(it, T.p&#x5B;T.z]){\r\n                        int x = T.x + it-&gt;fi, y = T.y + it-&gt;se;\r\n                        if (i == x &amp;&amp; y == j){\r\n                            cout &lt;&lt; &quot;x&quot;;\r\n                            bj = true;\r\n                        }\r\n                    }\r\n                    if (!bj)\r\n                    cout &lt;&lt; G&#x5B;i]&#x5B;j];\r\n                }\r\n                cout &lt;&lt; endl;\r\n            }\r\n            cout &lt;&lt; endl;*\/\r\n\r\n\r\n        }\r\n}\r\n\r\n\r\nint main() {\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n    \/\/freopen(&quot;out.txt&quot;, &quot;w&quot;, stdout);\r\n#endif\r\n\r\n    Rush{\r\n        OT(Run());\r\n    }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem F. Tetris Brief description: \u6a21\u62df\u4fc4\u7f57\u65af\u65b9\u5757\u6e38\u620f\u3002 Analysis: Dead-do const int N = 12, M = 9; bool G&#x5B;20]&#x5B;20]; bool inGrid(int x, int y){ return x &gt;= 0 &amp;&amp; y &gt;= 0 &amp;&amp; x &lt; N &amp;&amp; y &lt; M; } struct T{ VVII p; int x, y, z; void ww(){ int zz = z; ++zz; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[104],"tags":[],"class_list":["post-1196","post","type-post","status-publish","format-standard","hentry","category-multi-university-training"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-ji","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=1196"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1196\/revisions"}],"predecessor-version":[{"id":1209,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/1196\/revisions\/1209"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=1196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=1196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=1196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}