大佬求调,14分查了很多遍
  • 板块P3392 涂国旗
  • 楼主ljhhh7327
  • 当前回复2
  • 已保存回复2
  • 发布时间2025/7/31 10:01
  • 上次更新2025/7/31 15:08:32
查看原帖
大佬求调,14分查了很多遍
1789277
ljhhh7327楼主2025/7/31 10:01
#include<iostream>
#include<cmath>
#include<string>
using namespace std;
string in[51];
int main(){
	int n,m;
	cin>>n>>m;
	cin.ignore();
	for(int i=0;i<n;i++)
	getline(cin,in[i]);
	int ans=2501,l1,l2;
	for(int i=0;i<=n-3;i++)
	{
		for(int j=i+1;j<=n-2;j++)
		{
			int tem=0;
			for(int y=0;y<m;y++)
			{
				for(int x=0;x<=i;x++)
					if(in[x][y]!='W')	++tem;
				for(int x=i+1;x<=j;x++)
					if(in[x][y]!='B')	++tem;
				for(int x=j+1;x<n;x++)
					if(in[x][y]!='R')	++tem;	
			}
			if(ans>tem)
			{
				ans=tem;l1=i;l2=j;
			}
		}
	}
	cout<<ans;
	return 0;
}

2025/7/31 10:01
加载中...