QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#659485 | #5414. Stop, Yesterday Please No More | Zlin05 | WA | 5ms | 6024kb | C++23 | 2.5kb | 2024-10-19 20:24:05 | 2024-10-19 20:24:06 |
Judging History
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;
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;
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: 5804kb
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: 6024kb
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 6 81 12 15 10 240 15 0 0 7 14 18 24 5 42 9 99 4 1 2 2 121 8 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 72 0 6 27...
result:
wrong answer 3rd numbers differ - expected: '20', found: '6'