⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1006.cpp

📁 我的URAL的1000 ~ 1050 的全部代码 包含WA 最后AC的程序 有2~3个比较难的是MAIGO的程序
💻 CPP
字号:
//找到一个框框之后,把它拿掉,被它覆盖的地方标上?。?可以代表任何东西。当我们只剩下?和.的时候,工作完成!// hint : all frame are square  x == y;#include <iostream>using namespace std;const int maxX = 50;const int maxY = 20;const char c1 = 218 , c2 = 191, c3 = 192, c4 = 217, cv = 179, ch = 196, any = '?';	//提交的时候注意要改char map[maxY][maxX];int ans[2000][3];	// total sybol square lengthint cnt,totS;int min(int a, int b){ return a<b?a:b; }void readIn(){	int i, j;	totS = 0;	for( j = 0; j < maxY; j++ )	{		for( i = 0; i < maxX; i++ )		{			cin >> map[j][i];			if( map[j][i] != '.' ) totS++;		}	}}bool ok( int x, int y, int a ){	if( map[y][x] != c1 && map[y][x] != any )     	  return false;	if( map[y][x+a] != c2 && map[y][x+a] != any )	  return false;	if( map[y+a][x] != c3 && map[y+a][x] != any ) 	  return false;	if( map[y+a][x+a] != c4 && map[y+a][x+a] != any ) return false;	return true;}void clear( int x, int y ){	if( map[y][x] != '.' && map[y][x] != any ) 		{totS--;	map[y][x] = any;}}bool check( int x, int y , int a ){	int i;	for( i = x+1; i< x+a; i++ )	{		if( map[y][i] != ch && map[y][i] != any )return false;		if( map[y+a][i] != ch && map[y+a][i] != any )return false;	}	for( i = y+1; i < y+a; i++ )	{		if( map[i][x] != cv && map[i][x] != any )return false;		if( map[i][x+a] != cv && map[i][x+a] != any )return false;	}	int t = totS;	for( i = x; i <= x+a; i++ )		{clear(i,y); clear(i,y+a);}	for( i = y; i <= y+a; i++ )		{clear(x,i); clear(x+a,i);}	if( totS == t )return false;	else return true;}void output(){	int i;	cout << cnt << endl;	for( i = cnt; i >= 1; i-- )		cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] <<endl;}int main(){	int i, j, l;//	freopen("1006.in","r",stdin);	readIn();	while( totS > 0 )	{//		cout << totS <<endl;		for( l = 1; l < maxY; l++ )			for( i = 0; i < maxY - l; i++ )				for( j = 0; j < maxX - l; j++ )					if( ok(j, i, l) )						if( check(j, i, l) )						{							cnt++;						ans[cnt][0] = j, ans[cnt][1] = i, ans[cnt][2]= l+1;						}	}	output();	return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -