{"id":690,"date":"2020-03-25T14:54:15","date_gmt":"2020-03-25T06:54:15","guid":{"rendered":"http:\/\/kylelv.com\/?p=690"},"modified":"2020-03-25T14:54:15","modified_gmt":"2020-03-25T06:54:15","slug":"alist-stl","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=690","title":{"rendered":"A:List &#8211;STL"},"content":{"rendered":"\n<h2 class=\"has-text-align-center wp-block-heading\">A:List<\/h2>\n\n\n\n<p class=\"has-text-align-center\">\u603b\u65f6\u95f4\u9650\u5236:\u00a04000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB<\/p>\n\n\n\n<p>\u63cf\u8ff0<\/p>\n\n\n\n<p>\u5199\u4e00\u4e2a\u7a0b\u5e8f\u5b8c\u6210\u4ee5\u4e0b\u547d\u4ee4\uff1a<br>new id \u2014\u2014\u65b0\u5efa\u4e00\u4e2a\u6307\u5b9a\u7f16\u53f7\u4e3aid\u7684\u5e8f\u5217(id&lt;10000)<br>add id num\u2014\u2014\u5411\u7f16\u53f7\u4e3aid\u7684\u5e8f\u5217\u52a0\u5165\u6574\u6570num<br>merge id1 id2\u2014\u2014\u5408\u5e76\u5e8f\u5217id1\u548cid2\u4e2d\u7684\u6570\uff0c\u5e76\u5c06id2\u6e05\u7a7a<br>unique id\u2014\u2014\u53bb\u6389\u5e8f\u5217id\u4e2d\u91cd\u590d\u7684\u5143\u7d20<br>out id \u2014\u2014\u4ece\u5c0f\u5230\u5927\u8f93\u51fa\u7f16\u53f7\u4e3aid\u7684\u5e8f\u5217\u4e2d\u7684\u5143\u7d20\uff0c\u4ee5\u7a7a\u683c\u9694\u5f00<\/p>\n\n\n\n<p>\u8f93\u5165<\/p>\n\n\n\n<p>\u7b2c\u4e00\u884c\u4e00\u4e2a\u6570n\uff0c\u8868\u793a\u6709\u591a\u5c11\u4e2a\u547d\u4ee4( n\uff1c\uff1d\uff12\uff10\uff10\uff10\uff10\uff10)\u3002\u4ee5\u540en\u884c\u6bcf\u884c\u4e00\u4e2a\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u8f93\u51fa<\/p>\n\n\n\n<p>\u6309\u9898\u76ee\u8981\u6c42\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>\u6837\u4f8b\u8f93\u5165<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">16\nnew 1\nnew 2\nadd 1 1\nadd 1 2\nadd 1 3\nadd 2 1\nadd 2 2\nadd 2 3\nadd 2 4\nout 1\nout 2\nmerge 1 2\nout 1\nout 2\nunique 1\nout 1<\/pre>\n\n\n\n<p>\u6837\u4f8b\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1 2 3 \n1 2 3 4\n1 1 2 2 3 3 4\n\n1 2 3 4<\/pre>\n\n\n\n<p>\u5927\u6982\u5c31\u662flist\u6a21\u677f\u7ec3\u4e60<br>\u6ce8\u610funique\u4e4b\u524d\u8981sort<br>\u884c\u672b\u6709\u7a7a\u683c\uff1f\uff08\u4f3c\u4e4e\u53bb\u6389\u7a7a\u683c\u8fd8WA\u4e86\uff08\u8fd8\u662f\u6211\u5199\u9519\u4e86qaq<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;map>\n#include&lt;list>\n#include&lt;cmath>\n#include&lt;queue>\n#include&lt;cstdio>\n#include&lt;string>\n#include&lt;cstring>\n#include&lt;iostream>\n#include&lt;algorithm>\nusing namespace std;\n#define inf 1000000007\n#define ll long long\n#define N 10010\ninline int rd()\n{\n    int x=0,f=1;char ch=getchar();\n    while(ch&lt;'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}\n    while(ch>='0'&amp;&amp;ch&lt;='9'){x=x*10+ch-'0';ch=getchar();}\n    return x*f;\n}\nint n;\nchar op&#91;10];\nlist&lt;int>a&#91;N];\nint main()\n{\n    n=rd();\n    int x,y;\n    while(n--){\n        scanf(\"%s\",op);\n        if(op&#91;0]=='a'){\n            x=rd();y=rd();\n            a&#91;x].push_back(y);\n        }else if(op&#91;0]=='o'){\n            x=rd();\n            a&#91;x].sort();\n            for(list&lt;int>::iterator it=a&#91;x].begin();it!=a&#91;x].end();++it)\n                printf(\"%d \",*it);\n            puts(\"\");\n        }else if(op&#91;0]=='m'){\n            x=rd();y=rd();\n            a&#91;x].merge(a&#91;y]);\n        }else if(op&#91;0]=='u'){\n            x=rd();\n            a&#91;x].sort();\n            a&#91;x].unique();\n        }else x=rd();\n    }\n    return 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A:List \u603b\u65f6\u95f4\u9650\u5236:\u00a04000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB \u63cf\u8ff0 \u5199\u4e00\u4e2a\u7a0b\u5e8f\u5b8c\u6210\u4ee5\u4e0b\u547d\u4ee4\uff1anew i [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[60],"class_list":["post-690","post","type-post","status-publish","format-standard","hentry","category-70","tag-stl"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=690"}],"version-history":[{"count":1,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions"}],"predecessor-version":[{"id":691,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/690\/revisions\/691"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}