QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659472#5414. Stop, Yesterday Please No MoreZlin05WA 2ms6060kbC++232.4kb2024-10-19 20:20:282024-10-19 20:20:29

Judging History

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

  • [2024-10-19 20:20:29]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6060kb
  • [2024-10-19 20:20:28]
  • 提交

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);
        }
    }
    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];
//    for (int i = dif - n; i <= dif + n; i++) {
//        for (int j = dif - m; j <= dif + m; j++) {
//            cout << sum[i][j] << ' ';
//        }
//        cout << '\n';
//    }
    int ans = 0, now = (ry - ly + 1) * (rx - lx + 1) - k;
    if (now < 0) {
        ans = (k ? 0 : n * m);
    } 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;
                check = sum[ax][ay] - sum[ax][by] - sum[bx][ay] + sum[bx][by];
                if (check == now) ++ans;
            }
        }
    }
    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: 5848kb

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: 2ms
memory: 6060kb

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:

9
11
6
81
12
15
10
240
15
0
0
7
14
18
24
5
1
9
99
4
1
2
2
7
5
30
14
13
0
2
9
9
17
2
320
8
3
2
0
0
12
0
5
0
0
7
0
22
2
51
21
7
6
2
2
48
28
8
17
6
49
2
6
2
108
9
6
44
0
5
11
0
4
30
7
72
105
10
9
17
3
66
4
11
28
16
16
16
12
8
56
90
6
0
121
3
48
18
27
10
0
30
7
8
3
5
4
45
19
34
0
7
0
10
0
18
0
6
27
48
1...

result:

wrong answer 1st numbers differ - expected: '228', found: '9'