{"id":1742,"date":"2016-01-02T17:59:35","date_gmt":"2016-01-02T09:59:35","guid":{"rendered":"http:\/\/boweihe.me\/?p=1742"},"modified":"2016-01-02T17:59:35","modified_gmt":"2016-01-02T09:59:35","slug":"pat-1077-kuchiguse-20","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1742","title":{"rendered":"PAT 1077. Kuchiguse (20)"},"content":{"rendered":"<p>http:\/\/www.patest.cn\/contests\/pat-a-practise\/1077<br \/>\nThe Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker&#8217;s personality. Such a preference is called &#8220;Kuchiguse&#8221; and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle &#8220;nyan~&#8221; is often used as a stereotype for characters with a cat-like personality:<br \/>\n&nbsp;<\/p>\n<ul>\n<li>Itai nyan~ (It hurts, nyan~)<\/li>\n<li>Ninjin wa iyada nyan~ (I hate carrots, nyan~)<\/li>\n<\/ul>\n<p>&nbsp;<br \/>\nNow given a few lines spoken by the same character, can you find her Kuchiguse?<br \/>\n&nbsp;<br \/>\n\u8fd9\u4e2a\u9898\u76ee\u5c31\u662f\u5230\u7740\u627e\u6700\u957f\u76f8\u540c\u5b50\u4e32\uff0c\u6ca1\u5565\u96be\u5ea6\uff0c\u7528char\u6570\u7ec4\u64cd\u4f5c\u5f88\u65b9\u4fbf\uff0c\u76f4\u63a5\u7ed9\u4ee3\u7801<\/p>\n<pre class=\"lang:c++ decode:true \" title=\"PAT1077\">#include &lt;iostream&gt;\n#include &lt;string.h&gt;\nusing namespace std;\nbool tryMoveForward(int N, char** sentences, int* posPtr, bool &amp;contFlag)\n{\n\t\/\/\u5c1d\u8bd5\u5f53\u524d\u4f4d\u7f6e\u7684\u5b57\u7b26\u662f\u5426\u76f8\u540c\n\tchar chr = sentences[0][posPtr[0]];\n\tbool flag = true;\n\tint i = 0;\n\twhile(i &lt; N)\n\t{\n\t\tif (sentences[i][posPtr[i]] != chr)\n\t\t{\n\t\t\tflag = false;\n\t\t\tbreak;\n\t\t}\n\t\ti++;\n\t}\n\tif (flag)\n\t{\n\t\t\/\/Move forward\n\t\tfor (i = 0; i &lt; N; i++)\n\t\t{\n\t\t\tposPtr[i] --;\n\t\t\tif (posPtr[i] &lt;0)\n\t\t\t\tcontFlag = false;\n\t\t}\n\t}\n\treturn flag;\n}\nint main()\n{\n\tint N;\n\tcin &gt;&gt; N;\n\tchar **sentences = new char*[N]; \/\/\u5b58\u50a8\u53e5\u5b50\n\tint* posPtr = new int[N];\t\/\/\u5f53\u524d\u4f4d\u7f6e\u6307\u9488\n\t\/\/int maxSuffixStartPos = 0; \/\/\u6700\u957f\u5b50\u4e32\u8d77\u59cb\u4f4d\u7f6e(\u8ddd\u79bb\u6700\u540e\u4e00\u4e2a\u5b57\u7b26)\n\tcin.ignore(1);\n\tfor (int i = 0; i &lt; N; i++)\n\t{\n\t\tsentences[i] = new char[257];\n\t\t\/\/cin &gt;&gt; sentences[i];\n\t\tcin.getline(sentences[i], 257);\n\t\tposPtr[i] = strlen(sentences[i]) - 1;\n\t}\n\tbool contFlag = true;\n\twhile (contFlag)\n\t{\n\t\tbool movFlag = tryMoveForward(N, sentences, posPtr, contFlag);\n\t\tcontFlag &amp;= movFlag;\n\t}\n\t\/\/\u8bfb\u53d6\u6700\u957f\u5b57\u4e32\n\tint longSufPos = posPtr[0];\n\tif (longSufPos == strlen(sentences[0]) - 1)\n\t\tcout &lt;&lt; \"nai\";\n\telse\n\t{\n\t\tchar* result = sentences[0] + longSufPos + 1;\n\t\tcout &lt;&lt; result;\n\t}\n\treturn 0;\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>http:\/\/www.patest.cn\/contests\/pat-a-practise\/1077 The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker&#8217;s personality. Such a preference is called &#8220;Kuchiguse&#8221; and is often exaggerated artistically in Anime and Manga. For example, the artificial sentence ending particle &#8220;nyan~&#8221; is often used as a stereotype [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[84],"class_list":["post-1742","post","type-post","status-publish","format-standard","hentry","category-study","tag-pat"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1742"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1742\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}