http://code.google.com/codejam/contest/dashboard?c=1128486#s=p0

View Code
   
     
#include < iostream >
char ch[ 51 ][ 51 ];
using namespace std;
int main()
{
int t;
int n , m , k = 0 ;
int i,j;
cin
>> t;
while (t -- )
{
cin
>> n >> m;

for (i = 0 ;i < n; i ++ ) cin >> ch[i];

int j , i , sign = 0 ;
int ans = 0 ;
for ( i = 0 ; i < n ; i ++ )
{
for ( j = 0 ; j < m ; j ++ )
{
if ( ch[i][j] != ' / ' && ch[i][j] != ' \\ ' && ch[i][j] != ' . ' )
{
if (ch[i][j + 1 ] == ' # ' && ch[i + 1 ][j] == ' # ' && ch[i + 1 ][j + 1 ] == ' # ' )
{
ch[i][j]
= ' / ' ;
ch[i
+ 1 ][j] = ' \\ ' ;
ch[i][j
+ 1 ] = ' \\ ' ;
ch[i
+ 1 ][j + 1 ] = ' / ' ;

}
else { sign = 1 ; break ;}

}
}
if (sign == 1 ) break ;
}
for (i = 0 ;i < n;i ++ )
{
for (j = 0 ;j < m;j ++ )
if (ch[i][j] == ' # ' ){ ans = 1 ; break ;}

}
cout
<< " Case # " <<++ k << " : " << endl;

if (ans == 1 ) cout << " Impossible " << endl;
else
{
for (i = 0 ;i < n;i ++ )
cout
<< ch[i] << endl;
}

}
return 0 ;
}

你可能感兴趣的:(dashboard)