30分WA,样例能过,求大佬帮助
查看原帖
30分WA,样例能过,求大佬帮助
1090339
YU_Accepted楼主2024/5/21 23:40
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n = 0, na = 0, nb = 0, cnt1 = 0, cnt2 = 0;
	int temp1[205], temp2[205], a[405], b[405];
	memset(temp1, 0, sizeof(temp1));
	memset(temp2, 0, sizeof(temp2));
	memset(a, 0, sizeof(a));
	memset(b, 0, sizeof(b));
	cin >> n >> na >> nb;
	for(int i = 1; i <= na; i++) cin >> temp1[i];
	for(int i = 1; i <= nb; i++) cin >> temp2[i];
	for(int i = 1, j = 1; i <= n, j <= na; i++, j++)
	{
		a[i] = temp1[j];
		if(j == na && i != 10) j = 0;
		if(i == n) break;
	}
	for(int i = 1, j = 1; i <= n, j <= nb; i++, j++)
	{
		b[i] = temp2[j];
		if(j == nb && i <= 9) j = 0;
		if(i == n) break;
	}
	for(int i = 1; i <= n; i++)
	{
		if(a[i] == b[i]) cnt1 += 0, cnt2 += 0;
		else if(a[i] != b[i])
		{
			if(a[i] == 0)
			{
				if(b[i] == 1 || b[i] == 4)
				{
					cnt2++;
				}
				else
				{
					cnt1++;
				}
			}
			else if(a[i] == 1)
			{
				if(b[i] == 2 || b[i] == 4)
				{
					cnt2++;
				}
				else
				{
					cnt1++;
				}
			}
			else if(a[i] == 2)
			{
				if(b[i] == 3)
				{
					cnt2++;
				}
				else
				{
					cnt1++;
				}
			}
			else if(a[i] == 3)
			{
				cnt1++;
			}
			else if(a[i] == 4)
			{
				if(b[i] == 2 || b[i] == 3)
				{
					cnt1++;
				}
				else
				{
					cnt2++;
				}
			}
		}
	}
	cout << cnt1 << " " << cnt2;
	return 0;
}

现在30分,样例能过。请大佬帮忙看一眼,感激不尽。

2024/5/21 23:40
加载中...