QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#704833#5414. Stop, Yesterday Please No Morelzx2017WA 0ms3672kbC++201.4kb2024-11-02 21:13:532024-11-02 21:13:53

Judging History

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

  • [2024-11-02 21:13:53]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3672kb
  • [2024-11-02 21:13:53]
  • 提交

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;
	vx=vy=1;
	fx=n;fy=m;x=y=xx=xxx=yy=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=max(xx,x);xxx=min(xxx,x);
		yy=max(yy,y);yyy=min(yyy,y);
	}
	vx=xx+1;vy=yy+1;
	fx=n+xxx;fy=m+yyy;
	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];
			cout<<f[i][j]<<" ";
		}
		cout<<endl;
	}
		
			
	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: 0
Wrong Answer
time: 0ms
memory: 3672kb

input:

3
4 5 3
ULDDRR
4 5 0
UUUUUUU
4 5 10
UUUUUUU

output:

0 0 0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 0 0 
0 0 0 1 2 3 3 3 3 3 
0 0 0 1 3 5 5 5 5 5 
0 0 0 1 4 7 7 7 7 7 
0 0 0 1 4 7 7 7 7 7 
0 0 0 1 4 7 7 7 7 7 
0 0 0 1 4 7 7 7 7 7 
2
20
0

result:

wrong answer 1st numbers differ - expected: '2', found: '0'