全WA
  • 板块P3392 涂国旗
  • 楼主Gsmdog_H
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/10/9 20:58
  • 上次更新2023/11/5 11:25:02
查看原帖
全WA
313616
Gsmdog_H楼主2020/10/9 20:58
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

const char w = 'W' , b = 'B' , r = 'R';
int anss = 2147483647;

int main(){
	int n , m;
	char ans[100][100];
	
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= m; ++j){
			scanf("%c", &ans[i][j]);
		}
	}
	
	for(int i = 1; i <= n - 2; ++i){
		for(int j = i + 1; j < n; ++j){
			int sum = 0;
			
			for(int x = 1; x <= i; ++x){
				for(int y = 1; y <= m; ++y){
					if(ans[x][y] != w)
						sum++;
				}
			}	
			
			for(int x = i + 1; x <= j; ++x){
				for(int y = 1; y <= m; ++y){
					if(ans[x][y] != b)
						sum++;
				}
			}
			
			for(int x = j + 1; x <= n; ++x){
				for(int y = 1; y <= m; ++y){
					if(ans[x][y] != r)
						sum++;
				}
			}
			
			anss = min(anss , sum);
		}
	}
	
	printf("%d", anss);
	
	return 0;
}
2020/10/9 20:58
加载中...