#include<string>
using namespace std;
int main()
{
int n = 0, subnum = 0, check = 0, blocknum = 1, ans = 0;
int num[10] = { 0 };
char arr[9][9];
string s;
while (n < 9)
{
getline(cin, s);
for (int i = 0; i < s.length(); i++)
arr[n][i] = s[i];
n++;
}
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
subnum = arr[i][j] - '0';
if (subnum != 0)
num[subnum]++;
if (num[subnum] > 1)
{
ans = 1;
cout << "row" << i + 1 << " #" << arr[i][j] << endl;
break;
}
}
for (int j = 0; j < 10; j++)
num[j] = 0;
}
for (int i = 0; i < 9; i++)
{
for (int j = 0; j < 9; j++)
{
subnum = arr[j][i] - '0';
if (subnum != 0)
num[subnum]++;
if (num[subnum] > 1)
{
ans = 1;
cout << "column" << i + 1 << " #" << arr[j][i] << endl;
break;
}
}
for (int j = 0; j < 10; j++)
num[j] = 0;
}
for (int i = 0; i < 9; i += 3)
{
for (int j = 0; j < 9; j += 3)
{
check = 0;
for (int x = i; x < i + 3; x++)
{
for (int y = j; y < j + 3; y++)
{
subnum = arr[x][y] - '0';
if (subnum != 0)
num[subnum]++;
if (num[subnum] > 1)
{
ans = 1;
check = 1;
cout << "block" << blocknum << " #" << arr[x][y] << endl;
break;
}
}
if (check == 1)
break;
}
blocknum++;
for (int j = 0; j < 10; j++)
num[j] = 0;
}
}
if (ans == 0)
cout << "true" << endl;
return 0;
}
沒有留言:
張貼留言