QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#659459 | #5414. Stop, Yesterday Please No More | Zlin05 | WA | 5ms | 7680kb | C++23 | 2.4kb | 2024-10-19 20:17:24 | 2024-10-19 20:17:29 |
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 = 0, rx = ry = 2000;
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: 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: 7680kb
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 0 6 0 2 0 0 240 9 2 0 0 10 18 0 0 1 0 0 0 0 0 0 0 0 0 14 9 0 0 9 9 17 0 320 8 3 0 0 0 0 0 0 0 0 40 0 0 0 0 0 7 0 2 2 48 28 2 17 0 0 0 0 0 108 9 0 44 0 5 0 0 0 30 0 0 105 0 0 17 0 66 0 0 0 0 0 0 0 0 56 90 6 0 121 0 48 0 27 10 0 30 7 0 3 5 0 0 0 0 24 0 0 0 0 0 0 0 0 48 10 3 225 0 80 0 0 11 13 90 0 0...
result:
wrong answer 1st numbers differ - expected: '228', found: '9'