QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659509#5414. Stop, Yesterday Please No MoreZlin05WA 5ms5764kbC++232.7kb2024-10-19 20:29:522024-10-19 20:29:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-19 20:29:52]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:5764kb
  • [2024-10-19 20:29:52]
  • 提交

answer

//
// Created by Zlin on 2024/10/19.
//

#include "bits/stdc++.h"

using namespace std;

typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int dif = 1005;
int n, m, k, lx, rx, ly, ry;
int sum[3020][3020];

inline void Zlin() {
    cin >> n >> m >> k;
    string s;
    cin >> s;
    int x = 0, y = 0;
    lx = ly = 1, rx = m, ry = n;
    for (auto it: s) {
        if (it == 'U') {
            y++;
            ry = min(ry, n - y);
        } else if (it == 'D') {
            y--;
            ly = max(ly, 1 - y);
        } else if (it == 'L') {
            x--;
            lx = max(lx, 1 - x);
        } else {
            x++;
            rx = min(rx, m - x);
        }
    }
//    cout << lx << ' ' << rx << ' ' << ly << ' ' << ry << '\n';
    x = 0, y = 0;
    sum[dif][dif] = 1;
    for (auto it: s) {
        if (it == 'U') {
            y--;
        } else if (it == 'D') {
            y++;
        } else if (it == 'L') {
            x++;
        } else {
            x--;
        }
        if (x < -m || x > m || y < -n || y > n) continue;
        sum[x + dif][y + dif] = 1;
    }
    for (int i = dif - n; i <= dif + n; i++)
        for (int j = dif - m; j <= dif + m; j++)
            sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
    int ans = 0, now;
    if (lx > rx || ly > ry) {
        now = -k;
    } else {
        now = (rx - lx + 1) * (ry - ly + 1) - k;
    }
    if (now == 0) {
        ans = n * m;
    } else if (now < 0) {
        ans = 0;
    } else {
        for (int y = 1; y <= n; y++) {
            for (int x = 1, ax, ay, bx, by, check; x <= m; x++) {
                ax = rx - x + dif, ay = ry - y + dif;
                bx = lx - x - 1 + dif, by = ly - y - 1 + dif;
                ax = min(ax, dif + n), ay = min(ay, dif + m);
                check = sum[ax][ay] - sum[ax][by] - sum[bx][ay] + sum[bx][by];
                if (check == now) ++ans;
            }
        }
    }
//        for (int i = dif - n; i <= dif + n; i++) {
//        for (int j = dif - m; j <= dif + m; j++) {
//            cout << sum[i][j] << ' ';
//        }
//        cout << '\n';
//    }
//    cout << now << ' ';
    cout << ans << '\n';

    for (int i = dif - n; i <= dif + n; i++)
        for (int j = dif - m; j <= dif + m; j++)
            sum[i][j] = 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int ttt = 1;
    cin >> ttt;
    while (ttt--) Zlin();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5668kb

input:

3
4 5 3
ULDDRR
4 5 0
UUUUUUU
4 5 10
UUUUUUU

output:

2
20
0

result:

ok 3 number(s): "2 20 0"

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 5764kb

input:

1060
19 12 0
UDLDDUUUUDDDLLRDUDUURULUUUDRDUDRDRLRLRLULULLLDLDDRLUUUURUUUDDRLLRUUUDULURUULLRDRLRDDURDUUURRRLURLRUULRRUDURDLUUURDLURDDLUUURDDRLLURRDLRUDLRDRLLRRDRDDLDRURRRLUDULLLRUUDLRRURRDLLRRRDLLRDDDLRLRURURDDDL
11 1 0
UR
3 18 33
UDRLR
17 11 132
RLDRDLDRUU
6 10 13
UULUDDLRDLUUDLDD
1 15 0
D
6 20 50
D...

output:

228
11
20
99
18
15
34
240
15
0
0
13
14
18
26
16
42
19
108
8
2
2
3
121
8
30
16
21
0
8
10
9
17
5
320
11
7
3
0
0
12
0
11
0
0
14
0
22
9
51
23
7
6
4
2
48
28
8
17
22
49
13
10
4
108
10
18
44
0
13
11
0
4
30
14
99
105
10
14
17
15
66
10
11
28
52
34
56
33
14
56
90
14
0
121
3
48
30
36
13
0
30
7
8
3
11
16
45
20
...

result:

wrong answer 17th numbers differ - expected: '1', found: '42'