{"id":278,"date":"2023-08-19T21:52:56","date_gmt":"2023-08-19T13:52:56","guid":{"rendered":"http:\/\/ggapa.net:81\/?p=278"},"modified":"2023-08-23T11:39:44","modified_gmt":"2023-08-23T03:39:44","slug":"%e3%80%90lgr-155-div-3%e3%80%91%e6%b4%9b%e8%b0%b7%e5%9f%ba%e7%a1%80%e8%b5%9b-3-%e3%80%8cnnoi%e3%80%8dround-2-%e8%b5%9b%e5%90%8e%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"http:\/\/ggapa.net:81\/2023\/08\/19\/%e3%80%90lgr-155-div-3%e3%80%91%e6%b4%9b%e8%b0%b7%e5%9f%ba%e7%a1%80%e8%b5%9b-3-%e3%80%8cnnoi%e3%80%8dround-2-%e8%b5%9b%e5%90%8e%e6%80%bb%e7%bb%93\/","title":{"rendered":"\u3010LGR-155-Div.3\u3011\u6d1b\u8c37\u57fa\u7840\u8d5b #3 &\u300cNnOI\u300dRound 2 \u8d5b\u540e\u603b\u7ed3"},"content":{"rendered":"

\u524d\u8a00<\/h1>\n

\u8fd9\u662f\u849f\u84bb AK \u7684\u7b2c\u4e00\u573a\u8003\u8bd5\uff01
\n\u8ba9\u6211\u4eec\u606d\u559c\u5b83\uff01
\n

\"file\"<\/div>
\n\u6bd4\u8d5bid\uff1a124047<\/a><\/em><\/p>\n

T1 100pts<\/h1>\n

\u901a\u8fc7\u6570\u5b66\u8ba1\u7b97\u4e00\u4e0b\u9ad8\u5ea6\u5373\u53ef<\/p>\n

#include <iostream>\nusing namespace std;\nconst int maxn = 1e5 + 5;\n\nint n, T;\nint v[maxn], t[maxn], high[maxn];\n\nint main() {\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    cin >> n >> T;\n    for(int i = 1; i <= n; i++) {\n        cin >> v[i] >> t[i];\n        high[i] = max(T - t[i], 0) * v[i];\n    }\n    int minHigh = -1, index;\n    for(int i = 1; i <= n; i++) {\n        if(high[i] > minHigh) {\n            minHigh = high[i];\n            index = i;\n        }\n    }\n    cout << index << endl;\n}<\/code><\/pre>\n

T2 100pts<\/h1>\n

\u901a\u8fc7\u5206\u6790\u9898\u76ee\u53ef\u77e5\uff1a<\/p>\n

    \n
  • \u5982\u679c\u4fa6\u6d4b\u5230\u51b0\u5ddd\u7b2c\u4e00\u6b21\u878d\u5316\uff0c\u8f93\u51fa\u6700\u8fd1\u4e00\u4e2a\u8fd8\u6ca1\u6709\u878d\u5316\u7684\u51b0\u5ddd\u5373\u53ef\u3002<\/li>\n
  • \u5982\u679c\u6240\u6709\u51b0\u5ddd\u5747\u878d\u5316\u5219\u65e0\u89e3<\/li>\n
  • \u5982\u679c\u4fa6\u6d4b\u5230\u51b0\u5ddd\u4e0d\u662f\u7b2c\u4e00\u6b21\u878d\u5316\uff0c\u4e3a\u4e86\u4f7f\u5b57\u5178\u5e8f\u6700\u5c0f\u8f93\u51fa 1 \u5373\u53ef\uff0c\u524d\u63d0\u662f\u51b0\u5ddd 1 \u5df2\u7ecf\u878d\u5316\uff0c\u5426\u5219\u65e0\u89e3\u3002<\/li>\n<\/ul>\n
    #include <iostream>\n#include <vector>\nusing namespace std;\n#define F "No solution"\n\nint n, m;\nchar info[1000005];\nvector<int> ans;\n\nint main() {\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    cin >> n >> m;\n    cin >> info;\n    int now = 1;\n    for(int i = 0; i < m; i++) {\n        if(info[i] == 'N') {\n            ans.push_back(now++);\n        }\n        else {\n            if(now == 1) {\n                cout << F << endl;\n                return 0;\n            }\n            ans.push_back(1);\n        }\n    }\n    if(now > n + 1) {\n        cout << F << endl;\n        return 0;\n    }\n    for(int i = 0; i < ans.size(); i++)     {\n        cout << ans[i] << " ";\n    }\n    return 0;\n}<\/code><\/pre>\n

    T3 100pts<\/h1>\n

    \u7528\u7684 STL \u505a\u7684\uff0c\u9898\u76ee\u6d89\u53ca\u5230\u521d\u4e2d\u6570\u5b66\u4e00\u6b21\u51fd\u6570<\/p>\n

    \u4ee4 $y_1 = k_1x + b_1$\uff0c$y_2 = k_2x + b_2$<\/p>\n

    \u5982\u679c\u4e24\u6761\u76f4\u7ebf\u4ec5\u6709\u4e00\u4e2a\u4ea4\u70b9\uff0c\u5219\uff1a<\/p>\n

      \n
    • $k_1 \\ne k_2$<\/li>\n<\/ul>\n

      \u82e5\u4e24\u6761\u76f4\u7ebf\u81f3\u5c11\u6709\u4e00\u4e2a\u7126\u70b9\uff0c\u5219\uff1a<\/p>\n

        \n
      • $k_1 \\ne k_2 || (k_1 = k_2 \\& b_1 = b_2)$<\/li>\n<\/ul>\n

        \u8d77\u521d\u6211\u672c\u6765\u60f3\u7528\u4e00\u4e2a\u4e8c\u7ef4 map \u6765\u8bb0\u5f55\u6bcf\u4e00\u4e2a\u4e00\u6b21\u51fd\u6570\uff0c\u4f46\u662f\u6211\u53d1\u73b0\u8fd9\u6837\u5b50\u8fdb\u884c\u64cd\u4f5c2<\/code>\u6216\u64cd\u4f5c3<\/code>\u592a\u6162\u4e86\uff0c\u4f1aTLE<\/p>\n

        \u4f46\u662f\u901a\u8fc7\u4e4b\u524d\u7684\u63a8\u8bba\u6211\u4eec\u77e5\u9053\u4e86\u8fdb\u884c\u64cd\u4f5c2<\/code>\u53ea\u9700\u8981\u77e5\u9053 $k$ \u5c31\u884c\u4e86\uff0c\u6240\u4ee5\u8bf4\u6211\u4eec\u53ef\u4ee5\u62ff\u4e00\u4e2a map \u51fa\u6765\u5b58\u653e $k$ \u76f8\u540c\u7684\u6570\u91cf\uff0c\u9700\u8981\u8be2\u95ee\u7684\u65f6\u5019\u76f4\u63a5\u8f93\u51fa\u4e00 $\u6b21\u51fd\u6570\u6570\u91cf\u603b\u548c - (\u659c\u7387 = k\u7684\u4e00\u6b21\u51fd\u6570\u7684\u6570\u91cf)$<\/p>\n

        \u9047\u5230\u5220\u9664\u5c31\u4e0d\u884c\u4e86\uff0c\u5220\u9664\u65f6\u4e0e\u7ed9\u5b9a\u7684\u4e00\u6b21\u51fd\u6570\u76f8\u540c\u7684\u4e00\u6b21\u51fd\u6570\u4e5f\u4f1a\u88ab\u5220\u9664\u6389\uff0c\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u8fd8\u662f\u9700\u8981\u4e00\u4e2a\u4e8c\u7ef4 map \u6765\u8bb0\u5f55\u6bcf\u4e00\u4e2a\u4e00\u6b21\u51fd\u6570\uff0c\u5728\u5220\u9664\u7684\u65f6\u5019\u628a\u9664\u4e86\u91cd\u5408\u6240\u6709\u659c\u7387\u76f8\u540c\u7684\u4e00\u6b21\u51fd\u6570\u5220\u9664\u5373\u53ef\u3002<\/p>\n

        \u4f46\u662f\u8fd9\u6837\u5b50\u8fd8\u662f TLE \u4e86\uff0c\u5361\u4e86\u4e00\u4e0b\u6570\u636e\u8303\u56f4\u5c31\u8fc7\u4e86\u3002<\/p>\n

        #include <iostream>\n#include <map>\n#include <set>\n#include <vector>\nusing namespace std;\n\nint n;\nmap<int, map<int, int> > linesmall;\nmap<int, int> linebig;\n\nint main() {\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    cin >> n;\n    int sum = 0;\n    while(n--) {\n        int cz;\n        cin >> cz;\n        int k, b;\n        cin >> k >> b;\n        if(cz == 1) {\n            linesmall[k][b]++;\n            sum++;\n            linebig[k]++;\n        }\n        if(cz == 2) {\n            cout << sum - linebig[k] << '\\n';\n        }\n        if(cz == 3) {\n            sum = linebig[k] - linesmall[k][b];\n            map<int ,int> tmp;\n            linesmall[k][b] = 0;\n            if(abs(k) <= 50)tmp = linesmall[k];\/\/\u6700\u540e\u4e00\u4e2a\u6570\u636e\u70b9\u8c8c\u4f3c\u975e\u5e38\u6c34\uff0c\u4e0d\u9700\u8981\u8fd9\u53e5\u8bdd\u5c31\u53ef\u4ee5 A. \u4f46\u662f\u6709\u4e86\u4f1a TLE\uff0c \u6240\u4ee5\u8bf4\u5c31\u7279\u5224\u4e00\u4e0b\u4e3a\u4e86\u9632\u6b62 Subtask 2 \u51fa\u9519\n            linesmall.clear();\n            linebig.clear();\n            linebig[k] = sum;\n            linesmall[k] = tmp;\n            tmp.clear();\n        }\n    }\n    return 0;\n}<\/code><\/pre>\n

        T4 100pts<\/h1>\n

        \u8fd9\u9053\u9898\u4e00\u5f00\u59cb\u4e0d\u5bb9\u6613\u770b\u61c2\uff0c\u4f46\u901a\u8fc7\u63a8\u7406\u6211\u4eec\u77e5\u9053 $S^k$ \u5c31\u76f8\u5f53\u4e8e\u628a\u5b57\u7b26\u4e32 $S$ \u7ffb $k$ \u500d\u3002<\/p>\n

        \u56e0\u4e3a\u53ef\u4ee5\u65e0\u9650\u7ffb\u500d\uff0c\u6240\u4ee5\u8bf4\u9664\u4e86 $S$ \u4e2d\u4e0d\u5b58\u5728\u7684\u6570\u4e4b\u5916\uff0c\u6700\u957f\u516c\u5171\u5b50\u5e8f\u5217\u7684\u957f\u5ea6\u5c31\u662f $T\\cup S$ \u5143\u7d20\u7684\u6570\u91cf<\/p>\n

        \u800c $k$ \u4e5f\u5f88\u597d\u6c42\u4e86\u3002<\/p>\n

        #include <iostream>\n#include <vector>\nusing namespace std;\nconst int maxn = 1e6 + 5;\n\nint n, m, c1, c2, k = 1;\nint ans = 0;\nint a[maxn];\nbool used[maxn];\nvector<int> b(1);\nvector<int> index[maxn];\n\nint main() {\n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    cin >> n >> m >> c1 >> c2;\n    for(int i = 1; i <= n; i++) {\n        cin >> a[i];\n        used[a[i]] = true;\n        index[a[i]].push_back(i);\n    }\n    int ans = 0;\n    for(int i = 1, tmp; i <= m; i++) {\n        cin >> tmp;\n        if(used[tmp]) b.push_back(tmp);\n        ans += used[tmp];\n    }\n    int it = 0;\n    for(int i = 1; i < b.size(); i++) {\n        bool suc = true;\n        while(suc){\n            suc = true;\n            for(int j = 0; j < index[b[i]].size(); j++) {\n                if(index[b[i]][j] > it) {\n                    it = index[b[i]][j];\n                    suc = false;\n                    break;\n                }\n            }\n            if(suc) {\n                k++;\n                it = 0;\n            }\n        }\n    }\n    cout << c1 * ans << " " <<c2 * k;\n    return 0;\n}<\/code><\/pre>\n

        \u603b\u7ed3<\/h1>\n
          \n
        • \n

          \u8003\u8bd5\u9700\u8981\u6709\u7075\u6d3b\u7684\u601d\u7ef4<\/p>\n<\/li>\n

        • \n

          \u8c03\u8bd5\u4ee3\u7801\u7684\u80fd\u529b\u771f\u7684\u84bb\u7206\u4e86<\/p>\n<\/li>\n

        • \n

          \u4e0b\u6b21\u8003\u8bd5\u4e0d\u8981\u518d\u8fdf\u5230\u4e86\uff01\uff01\uff01<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"

          \u524d\u8a00 \u8fd9\u662f\u849f\u84bb AK \u7684\u7b2c\u4e00\u573a\u8003\u8bd5\uff01 \u8ba9\u6211\u4eec\u606d\u559c\u5b83\uff01 \u6bd4\u8d5bid\uff1a124047 T1 100pts \u901a\u8fc7\u6570\u5b66\u8ba1\u7b97 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,11],"tags":[],"_links":{"self":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/278"}],"collection":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/comments?post=278"}],"version-history":[{"count":8,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":287,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/278\/revisions\/287"}],"wp:attachment":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/media?parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/categories?post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/tags?post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}