QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235519#5414. Stop, Yesterday Please No MoreMurphy_WA 3ms5952kbC++141.3kb2023-11-02 21:13:262023-11-02 21:13:26

Judging History

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

  • [2023-11-02 21:13:26]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5952kb
  • [2023-11-02 21:13:26]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define re register
#define il inline
#define N 1003
#define maxN 2050
#define Ls 1000006
using namespace std;
int n,m,k,a[maxN][maxN];
char s[Ls];
int main()
{
	int T;cin>>T;
	while(T--) {
		cin>>n>>m>>k>>s;
		int nu=1,nd=n,nl=1,nr=m;
		int mu=1,md=n,ml=1,mr=m;
		int x=N,y=N,ls=strlen(s);
		int B_x=N-n-3,E_x=N+n+3,B_y=N-m-3,E_y=N+m+3;a[x][y]=1;
		for(int i=0;i<ls;i++) {
			if(s[i]=='U') nu++,nd++,x++;
			else if(s[i]=='D') nu--,nd--,x--;
			else if(s[i]=='L') nl++,nr++,y++;
			else nl--,nr--,y--;
			mu=mu<nu?nu:mu;md=md>nd?nd:md;	
			ml=ml<nl?nl:ml;mr=mr>nr?nr:mr;
			if(B_x<=x&&x<E_x&&B_y<=y&&y<E_y) a[x][y]=1;
		}
		if(mu>md||ml>mr) {
			if(k==0) cout<<(n*m)<<endl;
			else cout<<0<<endl; continue;
		}
		int ns=(mr-ml+1)*(md-mu+1),ans=0;
		if(ns<k) {cout<<0<<endl; continue;}
		for(int i=B_x;i<=E_x;i++)
			for(int j=B_y;j<=E_y;j++)
				a[i][j]+=a[i][j-1]+a[i-1][j]-a[i-1][j-1];
		for(int i=N-n;i<N;i++)
			for(int j=N-m;j<N;j++) {
				//有交集
				int x=i+mu,xx=i+md,y=j+ml,yy=j+mr;
				int ss=a[xx][yy]-a[x-1][yy]-a[xx][y-1]+a[x-1][y-1];
				if(ns-ss==k) ans++;
			}
		cout<<ans<<endl;
		for(int i=B_x;i<=E_x;i++)
			for(int j=B_y;j<=E_y;j++)
				a[i][j]=0;
		
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5652kb

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: 3ms
memory: 5952kb

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

result:

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