{"id":174,"date":"2023-08-14T12:26:32","date_gmt":"2023-08-14T04:26:32","guid":{"rendered":"http:\/\/puhongyi.net:81\/?p=174"},"modified":"2023-09-16T21:37:00","modified_gmt":"2023-09-16T13:37:00","slug":"%e3%80%90lgr-154-div-4%e3%80%91%e6%b4%9b%e8%b0%b7%e5%85%a5%e9%97%a8%e8%b5%9b-15-%e8%b5%9b%e5%90%8e%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"http:\/\/ggapa.net:81\/2023\/08\/14\/%e3%80%90lgr-154-div-4%e3%80%91%e6%b4%9b%e8%b0%b7%e5%85%a5%e9%97%a8%e8%b5%9b-15-%e8%b5%9b%e5%90%8e%e6%80%bb%e7%bb%93\/","title":{"rendered":"\u3010LGR-154-Div.4\u3011\u6d1b\u8c37\u5165\u95e8\u8d5b #15 \u8d5b\u540e\u603b\u7ed3"},"content":{"rendered":"

\u3010LGR-154-Div.4\u3011\u6d1b\u8c37\u5165\u95e8\u8d5b #15 \u8d5b\u540e\u603b\u7ed3<\/h1>\n

\u6574\u4f53\u8bc4\u4ef7<\/h2>\n

\u4ee5\u6211\u7684\u6c34\u5e73\u5c31\u53ea\u80fd\u505a\u505a\u5165\u95e8\u8d5b\u4e86\uff0c\u5176\u4ed6\u7684\u6bd4\u8d5b\u6839\u672c\u63d0\u4e0d\u4e0a\u52b2\u3002<\/p>\n

Debug\u901f\u5ea6\u592a\u6162\u5bfc\u81f4\u9898\u76ee\u6ca1\u6709\u505a\u5b8c\u3002<\/p>\n

\"\"<\/div><\/p>\n

T1 443 pts (500 pts)<\/h2>\n

\u8003\u8bd5\u7684\u65f6\u5019\u8fdf\u5230\u4e86\u5341\u5206\u949f\u3002
\n\u7b2c\u4e00\u9898\u8fd8\u662f\u5f88\u7b80\u5355\u4e00\u4e2a\u987a\u5e8f\u7ed3\u6784\u5c31\u53ef\u89e3\u51b3\u95ee\u9898<\/p>\n

#include <iostream>\nusing namespace std;\nint a, b, c, d;\nint main() {\n    cin >> a >> b >> c >> d;\n    int sum = a + b + c + d;\n    if(sum < 51) {\n        cout << "Rabbit wins" << endl;\n    }\n    else {\n        cout << "Rabbit lose" << endl;\n    }\n    return 0;\n}<\/code><\/pre>\n

T2 562 pts (700 pts)<\/h2>\n

\u7528\u679a\u4e3e\u5373\u53ef\u89e3\u51b3\u95ee\u9898<\/p>\n

#include <iostream>\n#include <cstdio>\nusing namespace std;\nint sx, sy, cx, cy, mx, my;\nint fx[8] = {-1, -2, -2, -1, 1, 2, 2, 1};\nint fy[8] = {-2, -1, 1, 2, 2, 1, -1, -2};\nbool check(int x,int y) {\n    int sum = 0;\n    for(int i = 0; i < 8; i++) {\n        int nx = fx[i] + x;\n        int ny = fy[i] + y;\n        if((nx == sx && ny == sy) || (nx == cx && ny == cy)) sum++;\n        if(sum == 2) {\n            return true;\n        }\n    }\n    return false;\n}\nint main() {    \n    cin >> sx >> sy >> cx >> cy >> mx >> my;\n    for(int i = 0; i < 8; i++) {\n        int nx = fx[i] + mx;\n        int ny = fy[i] + my;\n        if(check(nx, ny)) {\n            cout << "Yes";\n            return 0;\n        }\n    }\n    cout << "No" << endl;\n    return 0;\n}<\/code><\/pre>\n

T3 772 pts (900pts)<\/h2>\n

\u4e00\u4e2a\u627e\u89c4\u5f8b\uff0c\u52a0\u4e0a\u4e00\u4e2aSTL map\u5373\u53ef\u89e3\u51b3\u95ee\u9898<\/p>\n

#include <iostream>\n#include <map>\nusing namespace std;\n\nmap<int,int> M;\nint n;\n\nint main() {\n    for(int i = 1; i <= 6; i += 2) {\n        M[i] = i + 1;\n        M[i + 1] = i;\n    }\n    cin >> n;\n    int ans = 0;\n    for(int i = 1, op; i <= n; i++) {\n        cin >> op;\n        if(i == n) {\n            ans += 21 - M[op];\n        }\n        else {\n            ans += 21 - M[op] - op;\n        }\n    }\n    cout << ans << endl;\n    return 0;\n}<\/code><\/pre>\n

T4 681 pts (1100pts)<\/h2>\n

\u66b4\u529b\u52a0\u4e0a\u4e00\u4e2a\u5b58\u653eMax\u7684\u6570\u7ec4\u5373\u53ef<\/p>\n

#include <iostream>\n#include <algorithm>\n#include <limits.h>\nusing namespace std;\nconst int maxn = 1e6 + 5;\ntypedef long long ll;\n#define int long long\nint n, c;\nint a[maxn], Max[maxn];\n\nsigned main() {\n    cin >> n >> c;\n    Max[0] = 0;\n    for(int i = 1; i <= n; i++) {\n        cin >> a[i];\n        Max[i] = max(Max[i - 1], a[i]);\n    }\n    ll ansval = LLONG_MAX;\n    int ansindex;\n    for(int k = 0; k <= n; k++) {\n        ll t = Max[k] + c * (n - k);\n        if(t < ansval) {\n            ansval = t;\n            ansindex = k;\n        }\n    }\n    cout << ansindex << " " << ansval << endl;\n    return 0;\n}<\/code><\/pre>\n

T5 852 pts (1300 pts)<\/h2>\n

Map \u5373\u53ef\u8f7b\u677e\u89e3\u51b3<\/p>\n

#include <iostream>\n#include <map>\nusing namespace std;\n\nint n, m;\nmap <int, int> score;\n\nint main() {\n    cin >> n >> m;\n    int vacant = 0;\n    for(int i = 1, kkksc03; i <= n; i++){\n        cin >> kkksc03;\n        score[kkksc03] = -1;\n    }\n    for(int i = 1, x, y; i <= m; i++) {\n        cin >> x >> y;\n        score[x] = y;\n    }\n    int ans = 0;\n    for(auto i = score.begin(); i != score.end(); i++) {\n        if(i->second < 60) ans++;\n        if(i->second == -1) vacant ++;\n    }\n    cout << vacant << "\\n" << ans << "\\n";\n    return 0;\n}<\/code><\/pre>\n

T6 713 pts (1300 pts)<\/h2>\n

\u5c31\u662f\u8fd9\u9053\u9898\u76ee\u628a\u6211\u5361\u4f4f\u4e86\uff0c\u68c0\u67e5\u4e86\u5f88\u4e45\uff0c\u7ed3\u679c\u53d1\u73b0\u662f\u6570\u7ec4\u5f00\u5c0f\u4e86
\n\u770b\u6765\u5982\u679c\u4e00\u9053\u9898\u4e0d\u662f\u72060\u5e94\u8be5\u5148\u68c0\u67e5\u6570\u636e\u7c7b\u578b\uff0c\u6570\u7ec4\u662f\u4e0d\u662f\u5f00\u5c0f\u4e86\uff0c\u50cf\u8fd9\u79cd\u4e00\u822c\u4f60\u7684\u601d\u8def\u662f\u5bf9\u7684\uff0c\u53ea\u4e0d\u8fc7\u662f\u5b9e\u73b0\u6302\u4e86<\/p>\n

#include <iostream>\n#include <vector>\nusing namespace std;\nconst int maxn = 500 * 500 + 5; \/\/\u5c31\u662f\u8fd9\u91cc\u7684\u95ee\u9898,\u4e4b\u524d\u5199\u6210500 + 5\uff0c\u6ca1\u6709\u8003\u8651\u5230\u5730\u56fe\u662f\u4e8c\u7ef4\u7684QAQ\nint n, m, N, M;\n\/*\nvector <int> mapH[maxn];\/\/\u96c4\u6027  \u6a2a\u5411\nvector <int> mapS[maxn];\/\/ts    \u7eb5\u5411\n*\/\nint xF[maxn], yF[maxn];\/\/\u96cc\u6027\nint xM[maxn], yM[maxn];\/\/xiong\n\nchar map[505][505];\n\nint main(){\n    cin >> n >> m >> N >> M;\n    int cnt = 1;\n    int cnt2 = 1;\n    for(int i = 1; i <= n; i++)\n        for(int j = 1; j <= m; j++) {\n            cin >> map[i][j];\n            if(map[i][j] == 'F') {\n                xF[cnt] = i;\n                yF[cnt++] = j;\n            }\n            if(map[i][j] == 'M') {\n                xM[cnt2] = i;\n                yM[cnt2++] = j;\n            }\n        }\n    int sum = 0;\n    for(int i = 1; i <= cnt; i++) {\n        int Run = 0;\n        int x, y;\n        x = xF[i];\n        y = yF[i];\n        while(map[x - 1][y] != 'M' && x - 1 >= 1) \n            x--;\n        if(x == 1) Run++;\n        x = xF[i];\n        y = yF[i];\n        while(map[x + 1][y] != 'M' && x + 1 <= n ) \n            x++;\n        if(x == n) Run++;\n        x = xF[i];\n        y = yF[i];\n        while(map[x][y - 1] != 'M' && y - 1 >= 1) \n            y--;\n        if(y == 1) Run++;\n        x = xF[i];\n        y = yF[i];\n        while(map[x][y + 1] != 'M' && y + 1 <= m) \n            y++;\n        if(y == m) Run++;\n        x = xF[i];\n        y = yF[i];\n        if(Run >= 3) \n            sum++;\n    }\n    for(int i = 1; i <= cnt2; i++) {\n        int Run = 0;\n        int x, y;\n        x = xM[i];\n        y = yM[i];\n        while(map[x - 1][y] != 'F' && x - 1 >= 1) \n            x--;\n        if(x == 1) Run++;\n        x = xM[i];\n        y = yM[i];\n        while(map[x + 1][y] != 'F' && x + 1 <= n) \n            x++;\n        if(x == n) Run++;\n        x = xM[i];\n        y = yM[i];\n        while(map[x][y - 1] != 'F' && y - 1 >= 1) \n            y--;\n        if(y == 1) Run++;\n        x = xM[i];\n        y = yM[i];\n        while(map[x][y + 1] != 'F' && y + 1 <= m) \n            y++;\n        if(y == m) Run++;\n        x = xM[i];\n        y = yM[i];\n        if(Run >= 3) \n            sum++;\n    }\n    cout << sum << endl;\n    return 0;\n}<\/code><\/pre>\n

T7 694 pts (1700 pts)<\/h2>\n

\u4e5f\u662fSTL map \u89e3\u51b3\u95ee\u9898<\/p>\n

#include <iostream>\n#include <algorithm>\n#include <cstring>\n#include <vector>\n#include <map>\nusing namespace std;\n\nmap<string, string> name;\n\nint main() {\n    int n, m, l;\n    cin >> n >> m >> l;\n    for(int i = 1; i <= n; i++) {\n        string Input;\n        cin >> Input;\n        name[Input] = Input;\n    }\n    for(int i = 1; i <= m; i++) {\n        string Input;\n        cin >> Input;\n        name.erase(Input);\n    }\n    for(int i = 1; i <= l; i++) {\n        string Input;   \n        cin >> Input;\n        name[Input] = Input;\n    }\n    vector <string> ls;\n    for(auto i = name.begin(); i != name.end(); i++) {\n        ls.push_back(i->second);\n    }\n    sort(ls.begin(), ls.end());\n    for(int i = 0; i < ls.size(); i++){\n        cout << ls[i] << endl;\n    }\n    return 0;\n}<\/code><\/pre>\n

T8 0 pts (2000 pts)<\/h1>\n

\u8fd9\u9053\u9898\u5728\u4e16\u754c\u8fd9\u4e48\u77ed\u7684\u60c5\u51b5\u4e0b\u505a\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u4e8e\u662f\u6211\u5c31\u8df3\u5230\u4e86T9<\/p>\n

T9 750pts (1500pts)<\/h1>\n

\u8fd9\u9053\u9898\u53ea\u770b\u4e86\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u7206int\u4e86<\/p>\n

#include <bits\/stdc++.h>\nusing namespace std;\nint main() {\n    int n, k;\n    cin >> n >> k;\n    if (k == n || k == 0) {\n        cout << "0 0" << endl;\n        return 0;\n    }\n    cout << "1 ";\n    if (k * 3 <= n)\/\/\u5c31\u662f\u8fd9\u91cc\u7206\u6389\u4e86\n        cout << 2 * k << endl;\n    else\n        cout << n - k << endl;\n    return 0;\n}<\/code><\/pre>\n

\u603b\u7ed3<\/h2>\n
    \n
  • debug\u80fd\u529b\u6709\u5f85\u63d0\u9ad8<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"

    \u3010LGR-154-Div.4\u3011\u6d1b\u8c37\u5165\u95e8\u8d5b #15 \u8d5b\u540e\u603b\u7ed3 \u6574\u4f53\u8bc4\u4ef7 \u4ee5\u6211\u7684\u6c34\u5e73\u5c31\u53ea\u80fd\u505a\u505a\u5165\u95e8\u8d5b\u4e86\uff0c\u5176\u4ed6\u7684\u6bd4\u8d5b […]<\/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":[20],"_links":{"self":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/174"}],"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=174"}],"version-history":[{"count":2,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":189,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/posts\/174\/revisions\/189"}],"wp:attachment":[{"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/ggapa.net:81\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}