72分求助!!!!1
查看原帖
72分求助!!!!1
895690
gghack_Nythix楼主2022/12/10 18:35
#include <bits/stdc++.h>
using namespace std;
char a[114][514];
int main()
{
	long long n,m,s = 10000000;
	cin >> n >> m;
	for(int i = 1;i <= n;i ++)
	{
		for(int j = 1;j <= m;j ++)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 1;i <= n;i ++)
	{
		for(int j = i + 1;j <= n - 2;j ++)
		{
			long long ans= 0;
			for(int k= 1;k <= i;k ++)
			{
				for(int g = 1;g <= m;g ++)
				{
					if(a[k][g] != 'W')
					{
						ans ++;
					}
				}
			}
			for(int k= i + 1;k <= j;k ++)
			{
				for(int g = 1;g <= m;g ++)
				{
					if(a[k][g] != 'B')
					{
						ans ++;
					}
				}
			}
			for(int k= j + 1;k <= n;k ++)
			{
				for(int g = 1;g <= m;g ++)
				{
					if(a[k][g] != 'R')
					{
						ans ++;
					}
				}
			}
			s = min(ans,s);
		}
	}
	cout << s;
	return 0;
}
2022/12/10 18:35
加载中...