static int to_index[255];
static void to_index_init(void)
{
to_index['R'] = 0;
to_index['G'] = 1;
to_index['B'] = 2;
}
static const char * solution(void)
{
vector<int> table[3];
char buf[2][16];
int grp = 0;
scanf("%s\n", buf[0]);
scanf("%s\n", buf[1]);
for (int i = 0; i < 9; i++)
table[to_index[buf[1][i]]].push_back(buf[0][i] - '0');
for (int i = 0; i < 3; i++)
{
if (table[i].empty())
continue;
if (table[i].size() % 3 != 0)
break;
int values[10] = { 0, };
for (int j = 0; j < table[i].size(); j++)
values[table[i][j]] += 1;
for (int j = 1; j <= 9; )
{
if (j + 2 <= 9 && values[j] && values[j + 1] && values[j + 2])
{
values[j] -= 1; values[j + 1] -= 1; values[j + 2] -= 1;
grp += 1;
}
else
j++;
}
for (int j = 1; j <= 9; j++)
{
if (values[j] >= 3)
{
grp += 1;
values[j] -= 3;
}
}
}
if (grp == 3)
return "Win";
else
return "Continue";
}
...