【枚举】URAL

//._. ... ._. ._. ... ._. ._. ._. ._. ._.
//|.| ..| ._| ._| |_| |_. |_. ..| |_| |_|
//|_| ..| |_. ._| ..| ._| |_| ..| |_| ._|
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef pair<int,int> Point;
char table[10][3][4]={
{
	"._.",
	"|.|",
	"|_|"
},
{
	"...",
	"..|",
	"..|"
},
{
	"._.",
	"._|",
	"|_."
},
{
	"._.",
	"._|",
	"._|"
},
{
	"...",
	"|_|",
	"..|"
},
{
	"._.",
	"|_.",
	"._|"
},
{
	"._.",
	"|_.",
	"|_|"
},
{
	"._.",
	"..|",
	"..|"
},
{
	"._.",
	"|_|",
	"|_|"
},
{
	"._.",
	"|_|",
	"._|"
}
};
char b[3][30];
bool cant[5][10];
int l[5],r[5],n;
int main()
{
	//freopen("d.in","r",stdin);
	l[1]=0; r[1]=2;
	l[2]=4; r[2]=6;
	l[3]=10; r[3]=12;
	l[4]=14; r[4]=16;
	scanf("%d",&n);
	Point Pre;
	for(int i=1;i<=n;++i)
	  {
	  	memset(cant,0,sizeof(cant));
	  	for(int j=0;j<3;++j)
	  	  scanf("%s",b[j]);
	  	for(int j=1;j<=4;++j)
	  	  {
	  	  	for(int p=0;p<10;++p){
	  	  	for(int k=0;k<3;++k)
	  	  	  for(int l1=0,l2=l[j];l1<3;++l1,++l2)
	  	  	    if(table[p][k][l1]=='.' && b[k][l2]!='.')
	  	  	      {
	  	  	      	cant[j][p]=1;
	  	  	      	goto OUT;
	  	  	      }
	  	  	      OUT:;
	  	  	  }
	  	  }
	  	for(int j=9;j>=0;--j)
	  	for(int k=9;k>=0;--k)
	  	for(int l=9;l>=0;--l)
	  	for(int p=9;p>=0;--p)
	  	  if((!cant[1][j]) && (!cant[2][k]) && (!cant[3][l]) && (!cant[4][p]) && (j<6 && l<6))
	  	    if(i==1 || Point(j*10+k,l*10+p)<Pre)
	  	      {
	  	      	printf("%d%d:%d%d
",j,k,l,p);
	  	      	Pre=Point(j*10+k,l*10+p);
	  	      	goto OU2;
	  	      }
	  	OU2:;
	  }
	return 0; 
}          
原文地址:https://www.cnblogs.com/autsky-jadek/p/6375221.html