安全驾驶,小心翻车。
R1A翻车了,R1B再走一遍。

T3居然没想出来,难过。

T1

随便统计一下就可以了

#include <bits/stdc++.h>
using namespace std;
int t, n, m;
int a[100020];
int b[100020];
int main() {
    cin >> t;
    for (int tt = 1; tt <= t; tt++) {
        cin >> n >> m;
        int x, y;
        char c;
        for (int i = 0; i <= m; i++) {
            a[i] = 0;
            b[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            cin >> x >> y >> c;
            if (c == 'W') {
                a[0]++;
                a[x]--;
            } else if (c == 'E') {
                a[x + 1]++;
            } else if (c == 'S') {
                b[0]++;
                b[y]--;
            } else if (c == 'N') {
                b[y + 1]++;
            }
        }
        for (int i = 1; i <= m; i++) {
            a[i] += a[i - 1];
            b[i] += b[i - 1];
        }
        int pa = max_element(a, a + m + 1) - a;
        int pb = max_element(b, b + m + 1) - b;
        printf("Case #%d: %d %d\n", tt, pa, pb);
    }
    return 0;
}

T2

大概就是只能询问2次,做法昭然若揭。

#include <bits/stdc++.h>
using namespace std;
int t, w;
int main() {
    cin >> t >> w;
    for (int tt = 0; tt < t; tt++) {
        cout << 200 << endl;
        fflush(stdout);
        long long x;
        cin >> x;
        int r4 = x >> 50 & 127;
        int r5 = x >> 40 & 127;
        int r6 = x >> 33 & 127;
        cout << 50 << endl;
        fflush(stdout);
        long long y;
        cin >> y;
        y -= r4 << (50 / 4);
        y -= r5 << (50 / 5);
        y -= r6 << (50 / 6);
        int r1 = y >> 50 & 127;
        int r2 = y >> 25 & 127;
        int r3 = y >> 16 & 127;
        cout << r1 << ' ' << r2 << ' ' << r3 << ' ' << r4 << ' ' << r5 << ' ' << r6 << endl;
        fflush(stdout);
        int z;
        cin >> z;
    }
    return 0;
}

T3

这个做法是暴力,正解待补……

#include <bits/stdc++.h>
using namespace std;
int t, n, m;
int c[1020][1020];
int d[1020][1020];
int main() {
    cin >> t;
    for (int tt = 1; tt <= t; tt++) {
        cin >> n >> m;
        for (int i = 0; i < n; i++) {
            cin >> c[i][i];
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                c[i][j] = max(c[i][j-1], c[j][j]);
            }
        }
        for (int i = 0; i < n; i++) {
            cin >> d[i][i];
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                d[i][j] = max(d[i][j-1], d[j][j]);
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                if (abs(c[i][j] - d[i][j]) <= m) {
                    ans++;
                }
            }
        }
        printf("Case #%d: %d\n", tt, ans);
    }
    return 0;
}
wwwwodddd Uncategorized

Leave a Reply

Your email address will not be published. Required fields are marked *