QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#625036 | #5414. Stop, Yesterday Please No More | study_to_death | WA | 2ms | 3808kb | C++14 | 1.1kb | 2024-10-09 17:13:54 | 2024-10-09 17:13:54 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e3 + 5, M = 1e6 + 5;
int g[N][N];
char s[M];
int n, m, k;
int u, d, l, r;
int du, dd, dl, dr;
void move(char str)
{
if(str == 'U')
{
if(du) du --;
else
{
u ++;
dd ++;
}
}else if(str == 'D')
{
if(dd) dd --;
else{
d --;
du ++;
}
}else if(str == 'R')
{
if(dr) dr --;
else
{
r --;
dl ++;
}
}else
{
if(dl) dl --;
else
{
l ++;
dr ++;
}
}
}
signed main()
{
int T;
scanf("%d", &T);
while(T -- )
{
int ans = 0;
scanf("%d%d%d", &n, &m, &k);
scanf("%s", s + 1);
u = l = 1;
d = n, r = m;
du = dd = dl = dr = 0;
for(int i = 1; s[i]; i ++ )
{
move(s[i]);
}
if((u > d || l > r) && k)
{
puts("0");
continue;
}else if((u > d || l > r) && !k)
{
int ans = n * m;
printf("%d\n", ans);
continue;
}
int x = (d - u + 1);
int y = (r - l + 1);
int num = x * y;
ans = num - k;
cout<<k - 1<<endl;
//cout<<u<<" "<<d<<" "<<l<<" "<<r<<endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
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: 3808kb
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 32 131 0 15 49 240 28 148 30 33 29 18 0 0 17 41 126 22 0 0 1 62 6 208 112 54 19 14 33 9 0 3 320 30 3 1 26 61 12 0 33 256 102 69 137 22 70 51 80 0 6 6 84 48 28 8 119 9 67 11 25 12 171 37 7 44 0 34 44 107 4 30 38 113 105 12 52 17 46 66 6 11 28 53 28 60 9 33 67 90 38 31 150 1 48 10 108 126 46 30...
result:
wrong answer 3rd numbers differ - expected: '20', found: '32'