{"id":40,"date":"2025-11-09T20:51:53","date_gmt":"2025-11-09T12:51:53","guid":{"rendered":"https:\/\/tblog.zeabur.app\/?p=40"},"modified":"2025-11-09T20:53:32","modified_gmt":"2025-11-09T12:53:32","slug":"%e9%a2%98%e8%a7%a3-p9938-usaco21open-acowdemia-ii-b","status":"publish","type":"post","link":"https:\/\/tblog.zeabur.app\/?p=40","title":{"rendered":"\u9898\u89e3 Luogu P9938 [USACO21OPEN] Acowdemia II B"},"content":{"rendered":"\n<p><a href=\"https:\/\/www.luogu.com.cn\/problem\/P9938\">\u9898\u76ee\u4f20\u9001\u95e8<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u9898\u76ee\u5927\u610f<\/h3>\n\n\n\n<p>\u6839\u636e\u7ecf\u8fc7\u8d21\u732e\u503c\u548c\u5b57\u5178\u5e8f\u6392\u5217\u540e\u7684\u5b57\u7b26\u4e32\u786e\u5b9a\u8d44\u5386\u6df1\u6d45\uff0c\u8d21\u732e\u503c\u5927\u7684\u8d44\u5386\u6d45\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u601d\u8def<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5229\u7528 STL \u4e2d\u7684 map \u5bb9\u5668\u5c06\u59d3\u540d\u4f5c\u4e3a\u4e0b\u6807\u5b58\u50a8\u8d21\u732e\u503c\u7684\u4f18\u5148\u7ea7\uff08STL \u5bb9\u5668\u4e0d\u719f\u7684<a href=\"https:\/\/oi-wiki.org\/lang\/csl\/associative-container\/\">\u70b9\u8fd9<\/a>\uff09\u3002<\/li>\n\n\n\n<li>\u5b9a\u4e49\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u5b58\u50a8 $n_i$ \u4e0e $n_j$ \u7684\u5927\u5c0f\u5173\u7cfb\uff0c\u4f18\u5148\u7ea7\u9ad8\u7684\u4e3a $1$\uff0c\u4f4e\u7684\u4e3a $0$\u200b\u3002<\/li>\n\n\n\n<li>\u5177\u4f53\u5b9e\u73b0\u8be6\u89c1\u4ee3\u7801\u6ce8\u91ca\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u4ee3\u7801\u5b9e\u73b0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u6539\u81eaYulicezzz\u7684\u4ee3\u7801\n#include&lt;bits\/stdc++.h&gt;\n#include&lt;ext\/pb_ds\/assoc_container.hpp&gt;\n#include&lt;ext\/pb_ds\/tree_policy.hpp&gt; \n#define int long long\nusing namespace std;\nusing namespace __gnu_pbds;\nconst int MAXN=1e5+7;\nmap&lt;string,int&gt;name;\nstring s&#91;MAXN];\nint mp&#91;1005]&#91;1005];\nint n,m;\nsigned main()         \n{     \n    cin&gt;&gt;m&gt;&gt;n;\/\/\u6309\u9898\u610f\u8f93\u5165\n    for(int i=1;i&lt;=n;i++)\n    {\n        cin&gt;&gt;s&#91;i];\n        name&#91;s&#91;i]]=i;\/\/map\u5b58\u50a8\u4f18\u5148\u7ea7\n    }\n    while(m--)\n    {\n        int l=1;\/\/\u8bb0\u5f55\u4e0a\u4e00\u4e2a\u7ea7\u522b\u7684\u6700\u540e\u4e00\u4e2a\u4f4d\u7f6e\n        s&#91;0]='z'+25;\n        for(int i=1;i&lt;=n;i++)\n        {\n            cin&gt;&gt;s&#91;i];\n            if(s&#91;i]&lt;s&#91;i-1])\n            {\n                l=i;\/\/\u66f4\u65b0\n            }\n            for(int j=1;j&lt;l;j++)\n            {\n                mp&#91;name&#91;s&#91;j]]]&#91;name&#91;s&#91;i]]]=-1;\/\/\u6839\u636e\u4f18\u5148\u7ea7\u5b58\u5165\u6570\u7ec4\n                mp&#91;name&#91;s&#91;i]]]&#91;name&#91;s&#91;j]]]=1;\n            }\n        }\n    }\n    for(int i=1;i&lt;=n;i++)\n    {\n        for(int j=1;j&lt;=n;j++)\n        {\n            if(i!=j)\n                mp&#91;i]&#91;j]==1?cout&lt;&lt;\"1\":mp&#91;i]&#91;j]==-1?cout&lt;&lt;\"0\":cout&lt;&lt;\"?\";\/\/\u8f93\u51fa\u77e9\u9635\n            else\n                cout&lt;&lt;\"B\";\/\/\u5982\u679c i=j \u5219\u8f93\u51fa B\n        }\n        puts(\"\");\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u65f6\u95f4\u590d\u6742\u5ea6<\/h3>\n\n\n\n<p>\u7ea6 $O(m \u22c5 n^2)$\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u4f20\u9001\u95e8 \u9898\u76ee\u5927\u610f \u6839\u636e\u7ecf\u8fc7\u8d21\u732e\u503c\u548c\u5b57\u5178\u5e8f\u6392\u5217\u540e\u7684\u5b57\u7b26\u4e32\u786e\u5b9a\u8d44\u5386\u6df1\u6d45\uff0c\u8d21\u732e\u503c\u5927\u7684\u8d44\u5386\u6d45\u3002 \u601d\u8def \u4ee3\u7801\u5b9e\u73b0 \u65f6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-oi","tag-oi"],"featured_image_src":null,"author_info":{"display_name":"CaelumRadish_c","author_link":"https:\/\/tblog.zeabur.app\/?author=1"},"_links":{"self":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=40"}],"version-history":[{"count":2,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions"}],"predecessor-version":[{"id":42,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/40\/revisions\/42"}],"wp:attachment":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}