QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#91610#5414. Stop, Yesterday Please No MoreWolamWA 2ms5676kbC++141.4kb2023-03-29 10:04:382023-03-29 10:04:40

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-29 10:04:40]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5676kb
  • [2023-03-29 10:04:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int sum[2005][2005],n,m,k,T;
char s[1000005];
int mxl,mxr,mxu,mxd;
int x,y;
void mov(char c)
{
	if(c=='L')y--;
	if(c=='R')y++;
	if(c=='U')x--;
	if(c=='D')x++;
}
signed main()
{
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
//	cin>>T;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d%d%s",&n,&m,&k,s+1);
		for(int i=0;i<=2*n+1;i++)
			for(int j=0;j<=2*m+1;j++)
				sum[i][j]=0;
		int len=strlen(s+1);
		x=n+1,y=m+1;
		mxl=mxr=mxu=mxd=0;
		sum[x][y]=1;
		for(int i=1;i<=len;i++)
		{
			mov(s[i]);
			if(x>=1&&x<=2*n+1&&y>=1&&y<=2*n+1)sum[x][y]=1;
			mxl=max(mxl,m+1-y);
			mxr=max(mxr,y-m-1);
			mxu=max(mxu,n+1-x);
			mxd=max(mxd,x-n-1);
		}
		//cerr<<mxl<<" "<<mxr<<" "<<mxu<<" "<<mxd<<endl;
		for(int i=1;i<=2*n+1;i++)
		{
			for(int j=1;j<=2*m+1;j++)
			{
				sum[i][j]+=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
			}
		}
		if(mxr+mxl>=m||mxu+mxd>=n)
		{
			if(k==0)
				printf("%d\n",n*m);
			else printf("0\n");
			continue;
		}
		int su=(n-mxu-mxd)*(m-mxl-mxr),ans=0;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=m;j++)
			{
				int x,y,xx,yy;
				x=n+2-i+mxu;y=m+2-j+mxl;
				xx=x+n-mxd-mxu-1,yy=y+m-mxl-mxr-1;
		//		cerr<<x<<" "<<y<<" "<<xx<<" "<<yy<<" ";
				int t=sum[xx][yy]-sum[x-1][yy]-sum[xx][y-1]+sum[x-1][y-1];
		//		cerr<<su<<" "<<t<<endl;
				if(su-t==k)
				{
		//			cerr<<i<<" "<<j<<endl;
					ans++;
				}
			}
		cout<<ans<<'\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3764kb

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: 5676kb

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
34
99
5
15
0
240
6
0
0
1
11
18
13
0
12
0
108
4
1
2
3
48
1
1
3
4
0
7
10
9
4
0
320
8
0
3
0
0
3
0
11
0
0
6
0
22
36
51
12
5
6
1
2
48
28
8
63
11
49
0
4
14
108
0
9
44
0
1
8
0
4
30
12
99
105
5
1
17
0
66
8
11
28
52
30
56
11
5
56
90
14
0
121
0
48
12
16
10
0
30
1
3
3
15
16
45
9
32
0
0
0
80
0
42
0
20
12...

result:

wrong answer 3rd numbers differ - expected: '20', found: '34'