QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#576184 | #5414. Stop, Yesterday Please No More | xinlengweishang | WA | 1ms | 4012kb | C++20 | 1.3kb | 2024-09-19 19:11:16 | 2024-09-19 19:11:17 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
map<char,int> gox,goy;
void slove(){
char s[100010];
map<int,map<int,int> > mp,f;
int dx=0,dy=0;
int minx=0,maxx=0,miny=0,maxy=0,y,x,k;
scanf("%d %d %d",&y,&x,&k);
scanf("%s",s);
mp[dy][dx]=0;
for(int i=0;s[i]!='\0';i++){
dx+=gox[s[i]];
dy+=goy[s[i]];
mp[-dy][-dx]=1;
minx=min(minx,dx);
maxx=max(maxx,dx);
miny=min(miny,dy);
maxy=max(maxy,dy);
}
int ymax=y-maxy,ymin=-miny;
int xmax=x-maxx,xmin=-minx;
int ans=(ymax-ymin)*(xmax-xmin);
if(ans<0){
printf("0\n");
return ;
}
else if(ans==0){
printf("%d\n",x*y);
return ;
}
ans-=k;
if(ans<0){
printf("0\n");
return ;
}
int tt=0;
for(int fy=-y+ymin-2;fy<=ymax;fy++){
for(int fx=-x+xmin-2;fx<=xmax;fx++){
f[fy][fx]=f[fy-1][fx]+f[fy][fx-1]-f[fy-1][fx-1];
if(mp[fy][fx]) f[fy][fx]++;
}
}
for(int fy=0;fy<y;fy++){
for(int fx=0;fx<x;fx++){
if(f[-fy+ymax][-fx+xmax]-f[-fy+ymax][-fx+xmin-1]-f[-fy+xmin-1][-fx+xmax]+f[-fy+ymin-1][-fx+xmin-1]==ans) tt++;
}
}
printf("%d\n",tt);
return ;
}
int main(){
gox['U']=0,goy['U']=1;
gox['D']=0,goy['D']=-1;
gox['L']=-1,goy['L']=0;
gox['R']=1,goy['R']=0;
int T=1;
scanf("%d",&T);
for(int i=1;i<=T;i++) slove();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4012kb
input:
3 4 5 3 ULDDRR 4 5 0 UUUUUUU 4 5 10 UUUUUUU
output:
8 0 0
result:
wrong answer 1st numbers differ - expected: '2', found: '8'