QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#373675 | #5414. Stop, Yesterday Please No More | XUAN_ | WA | 1ms | 5744kb | C++14 | 2.1kb | 2024-04-01 21:50:29 | 2024-04-01 21:50:29 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
const int N = 1e3+7;
template <typename T> inline void read(T &x){
T ch=getchar(),xx=1;x=0;
while(!isdigit(ch)) xx=ch=='-'?-1:xx,ch=getchar();
while(isdigit(ch)) x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
x*=xx;
}
template <typename T> void print(T x){
if(x<0) putchar('-'),x=-x;
if(x>9) print(x/10);
putchar(x%10+'0');
}
int n,m,k,f[N][N];
string s;
bool vis[N][N];
void pr(int x,int y,int l,int r){
if(vis[x][y]) return;
vis[x][y]=1;
int dx=min(n,x+l-1);
int dy=min(m,y+r-1);
// cout<<x<<" "<<y<<" "<<dx<<" "<<dy<<endl;
f[x][y]++;
f[dx+1][dy+1]++;
f[dx+1][y]--;
f[x][dy+1]--;
}
int main(){
int T;
read(T);
while(T--){
read(n),read(m),read(k);
int L,R,U,D,l,r,u,d;
L=U=l=u=1;
R=r=m,D=d=n;
cin>>s;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
vis[i][j]=0;
for(int i=0;i<s.length();++i){
switch(s[i]){
case 'D':u--,d--;break;
case 'U':u++,d++;break;
case 'R':l--,r--;break;
case 'L':l++,r++;break;
}
L=max(L,l);U=max(u,U);
R=min(R,r);D=min(D,d);
}
int M=(D-U+1)*(R-L+1);
if(D<U || R<L){
if(k==0) print(n*m);
else putchar('0');
putchar('\n');
continue;
}
M-=k;
if(M<0){
putchar('0');
putchar('\n');
continue;
}
int nn=D-U+1;
int mm=R-L+1;
int x=1+U-u;int y=1+L-l;
// cout<<x<<' '<<y<<" "<<x+nn-1<<' '<<y+mm-1<<endl;
pr(x,y,nn,mm);
for(int i=s.length()-1;i>=0;--i){
switch(s[i]){
case 'D':--x;break;
case 'U':++x;break;
case 'R':--y;break;
case 'L':++y;break;
}
pr(x,y,nn,mm);
}
int ans=0;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j){
f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
if(f[i][j]==M) ++ans;
}
print(ans);
putchar('\n');
}
return 0;
}
/*
3
4 5 3
ULDDRR
4 5 0
UUUUUUU
4 5 10
UUUUUUU
1
19 12 0
UDLDDUUUUDDDLLRDUDUURULUUUDRDUDRDRLRLRLULULLLDLDDRLUUUURUUUDDRLLRUUUDULURUULLRDRLRDDURDUUURRRLURLRUULRRUDURDLUUURDLURDDLUUURDDRLLURRDLRUDLRDRLLRRDRDDLDRURRRLUDULLLRUUDLRRURRDLLRRRDLLRDDDLRLRURURDDDL
*/
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5744kb
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: 0ms
memory: 4172kb
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 20 1 0 15 0 240 0 0 0 0 0 18 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 9 0 0 320 0 0 0 0 0 0 0 0 0 0 0 0 22 0 51 0 0 6 0 0 48 28 8 0 0 0 0 0 0 0 0 0 44 0 0 0 0 4 30 0 0 105 0 0 17 0 66 0 11 28 0 0 0 0 0 0 90 0 0 0 0 48 0 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 48 0 0 225 0 0 0 0 11 0 90 0 0 228 0 ...
result:
wrong answer 4th numbers differ - expected: '99', found: '1'