QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704671#5414. Stop, Yesterday Please No Morelzx2017WA 6ms8276kbC++201.2kb2024-11-02 20:35:162024-11-02 20:35:17

Judging History

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

  • [2024-11-02 20:35:17]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:8276kb
  • [2024-11-02 20:35:16]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int i,j,n,m,k,l,x,y,f[3001][3001],vx,vy,fx,fy,xx,yy,xxx,yyy,sum,t;
string s;
void solve(){
	cin>>n>>m>>k;
	cin>>s;
	x=y=xx=yy=xxx=yyy=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='U') x--;
		else if(s[i]=='D') x++;
		else if(s[i]=='L') y--;
		else y++;
		xx=min(xx,x);yy=min(yy,y);
		xxx=max(xxx,x);yyy=max(yyy,y);
	}
	vx=1+xxx;vy=1+yyy;
	fx=n+xx;fy=m+yy;
	if(fx<vx||fy<vy){
		if(k==0) cout<<n*m<<"\n";
		else cout<<"0\n";
		return;
	} 
	sum=(fx-vx+1)*(fy-vy+1);
	for(int i=0;i<=2*n;i++)
		for(int j=0;j<=2*m;j++) f[i][j]=0;
	x=n;y=m;f[x][y]=1;
	for(int i=0;i<s.size();i++){
		if(s[i]=='U') x++;
		else if(s[i]=='D') x--;
		else if(s[i]=='L') y++;
		else y--;
		if(x>=1&&x<=2*n&&y>=1&&y<=2*m) f[x][y]=1;
	}
	for(int i=1;i<=n*2;i++)
		for(int j=1;j<=m*2;j++)
			f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			xx=n-i;yy=m-j;
			int res=f[fx+xx][fy+yy]-f[fx+xx][vy-1+yy]-f[vx-1+xx][fy+yy]+f[vx-1+xx][vy-1+yy];
			if(sum-res==k) ans++;
		}
	cout<<ans<<endl;
}
signed main()
{
//	freopen("1.in","r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>t;
	while(t--) solve();
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3620kb

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: 6ms
memory: 8276kb

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

result:

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