君はまるで砂漠に咲く、一輪の花。

僕はその花に引き寄せられる蝶。

Codeforces Round #234 (Div. 2)

はい。
http://codeforces.com/contest/400

A. Inna and Choose Options

ざっくりと大意

・"X"or"O"の一列12枚のカードがある。
・プレイヤーはa・bで12になるようなa,bを選ぶ。
・aを行、bを列で12枚のカードを並べなおして縦一列に"X"が並ぶ箇所があれば勝ちなのでその並べ方を数え上げる。
・1x12の並べ方は1行12列のどこかに"X"があれば勝ちになる。

方針のようなもの

・丁寧に数える。

s=["1x12","2x6","3x4","4x3","6x2","12x1"]
x='X'
n=int(raw_input())
chk=0
ans=[[] for _ in range(n)]

for i in range(n):
    w=raw_input()
    if x in w:
        ans[i].append(s[0])

    l=[0]*6
    for j in range(12):
        if w[j]==x:
            l[j%6]+=1
    if 2 in l:
        ans[i].append(s[1])

    l=[0]*4
    for j in range(12):
        if w[j]==x:
            l[j%4]+=1
    if 3 in l:
        ans[i].append(s[2])

    l=[0]*3
    for j in range(12):
        if w[j]==x:
            l[j%3]+=1
    if 4 in l:
        ans[i].append(s[3])

    l=[0]*2
    for j in range(12):
        if w[j]==x:
            l[j%2]+=1
    if 6 in l:
        ans[i].append(s[4])

    if 'O' not in w:
        ans[i].append(s[5])

for i in range(n):
    if len(ans[i])>0:
        print str(len(ans[i]))+' '+' '.join(ans[i])
    else:
        print 0