求助
查看原帖
求助
953405
kevin_guoguo楼主2023/11/28 18:28

五个测试点全是WA

这是程序:

#include <bits/stdc++.h>
using namespace std;
int city[16+5][16+5];
int main()
{
	int a,b,n;
	cin>>a>>b;
	cin>>n;
	int x,y;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y;
		city[x][y]=-1;
	}
	for(int i=1;i<=a;i++)
	{
		if(city[i][1]==-1)
		{
			break;
		}
		else
		{
			city[i][1]=1;
		}
	}
	for(int i=1;i<=b;i++)
	{
		if(city[1][i]==-1)
		{
			break;
		}
		else
		{
			city[1][i]=1;
		}
	}
	for(int i=2;i<=a;i++)
	{
		for(int j=2;j<=b;j++)
		{
			if(city[i][j]!=-1)
			{
				city[i][j]=city[i-1][j]+city[i][j-1];
			}
		}
	} 
	cout<<city[a][b];
	return 0;
}

这是样例的测试结果

输入:
5 4
3
2  2
2  3
4  2
输出:
-5
2023/11/28 18:28
加载中...