QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#151502 | #5414. Stop, Yesterday Please No More | Miguel0312 | WA | 2ms | 7628kb | C++14 | 2.8kb | 2023-08-26 20:44:23 | 2023-08-26 20:44:24 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define F(i, a, b) for (int i = a; i < b; i++)
#define FE(i, a, b) for (int i = a; i <= b; i++)
#define FR(i, a, b) for (int i = a; i > b; i--)
#define FRE(i, a, b) for (int i = a; i >= b; i--)
#define ll \
long long // data types used often, but you don't want to type them time by
// time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOREACH(i, t) \
for (auto i = t.begin(); i != t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(), (c).end() // handy for function like "sort()"
#define IND(e, arr) find(begin(arr), end(arr), e) - begin(arr)
#define IOS \
ios_base::sync_with_stdio(0); // to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define N 1100
int dp[2 * N][2 * N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
string dir = "LDRU", s;
int t, n, m, k;
cin >> t;
while (t--) {
cin >> n >> m >> k;
ll x = 0, y = 0, l = 0, d = 0, r = 0, u = 0;
cin >> s;
for (int i = -n - 1; i <= n; i++) {
for (int j = -m - 1; j <= m; j++) {
dp[N + i][N + j] = 0;
}
}
dp[N][N] = 1;
for (char c : s) {
int index = dir.find(c);
x += dx[index], y += dy[index];
l = max(l, x);
r = max(r, -x);
u = max(u, -y);
d = max(d, y);
if (abs(x) <= m && abs(y) <= n) {
dp[N + y][N + x] = 1;
}
}
for (int i = -n; i <= n; i++) {
for (int j = -m; j <= m; j++) {
dp[N + i][N + j] += dp[N + i - 1][N + j] + dp[N + i][N + j - 1] -
dp[N + i - 1][N + j - 1];
}
}
ll cnt = n * m - (l + r) * n - (u + d) * (m - l - r);
cnt = max(cnt, 0ll) - k;
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int tmp;
if (l + r >= m || u + d >= n)
tmp = 0;
else
tmp = dp[N + (n - 1 - d) - i][N + (m - 1 - r) - j] -
dp[N + (u - 1) - i][N + (m - 1 - r) - j] -
dp[N + (n - 1 - d) - i][N + (l - 1) - j] +
dp[N + (l - 1) - i][N + (l - 1) - j];
if (tmp == cnt)
ans++;
}
}
cout << ans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5544kb
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: 7628kb
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:
0 11 3 99 9 15 16 240 6 0 0 7 9 18 23 0 6 16 108 4 1 2 4 6 0 15 4 12 0 7 10 9 2 5 320 9 5 3 0 0 4 4 11 0 0 7 0 22 39 51 12 1 6 2 2 48 28 8 63 22 49 13 5 4 108 10 9 44 0 13 8 0 4 30 12 103 105 9 14 17 0 66 9 11 28 52 15 56 11 6 56 90 14 0 121 3 48 2 29 10 0 30 5 8 3 9 17 45 20 34 1 20 0 2 0 32 0 20 1...
result:
wrong answer 1st numbers differ - expected: '228', found: '0'