Problem:


平面上の図形

縦 8、横 8 のマスからなる図 1 のような平面があります。

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

図１

この平面上に、以下の A から G の図形のどれかが一つだけ置かれています。

	

A

	

		
■■

		
■■

		

		

	

	

B

	

		
■

		
■

		
■

		
■

	

	

C

	

		
■■■■

		

		

		

	

	

D

	

		
■

		
■■

		
■

		

	

	

E

	

		
■■

		
■■

		

		

	

	

F

	

		
■

		
■■

		
■

		

	

	

G

	

		
■■

		
■■

		

		

	

		

たとえば、次の図 2 の例では E の図形が置かれています。

□□□□□□□□

□□□□□□□□

□■■□□□□□

□□■■□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

□□□□□□□□

図２

平面の中で図形が占めているマスを 1、占めていないマスを 0 で表現した数字の列を読み込んで、置かれている図形の種類（A〜G）を出力するプログラムを作成してください。

ただし、ひとつの平面に置かれている図形は必ず１つで、複数の図形が置かれていることはありません。また、A〜G で表される図形以外のものが置かれていることはありません。

Input

入力は複数のデータセットからなります。

１つのデータセットとして、平面の中で図形が占めているマスを 1、占めていないマスを 0 で表現した 8 文字からなる 8 つの文字列が与えられます。例えば、図 2 に対応する文字列の並びは次のようになります。

00000000

00000000

01100000

00110000

00000000

00000000

00000000

00000000

データセットの間は１つの空行で区切られています。データセットの数は 50 を超えません。

Output

各データセットごとに、平面に与えられた図形の種類（A〜G のいずれか）を１行に出力してください。

Sample Input

00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000

00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000

00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000

Output for the Sample Input

E
C
A



Sample input:
00000000
00000000
01100000
00110000
00000000
00000000
00000000
00000000

00011110
00000000
00000000
00000000
00000000
00000000
00000000
00000000

00000000
00000000
00110000
00110000
00000000
00000000
00000000
00000000


Sample output:
E
C
A

Submission status: Accepted

Solution code:
# -*- coding: utf8 -*-

import sys


types = ['A', 'B', 'C', 'D', 'E', 'F', 'G']


def main():
    while True:
        try:
            data = []
            for i in xrange(8):
                data.append(raw_input())

            check_figure(data)

            # 空行
            raw_input()
        except EOFError:
            break


def check_figure(data):
    # 最初の1を探す
    for i in xrange(8):
        for j in xrange(8):
            if data[i][j] == "1":
                for t in types:
                    if check_pattern(data, pattern(t, i, j)):
                        print t
                        return
                return


def pattern(p, i, j):
    if p == 'A':
        return [(i, j), (i, j + 1), (i + 1,  j), (i + 1, j + 1)]
    elif p == 'B':
        return [(i, j), (i + 1, j), (i + 2, j), (i + 3, j)]
    elif p == 'C':
        return [(i, j), (i, j + 1), (i, j + 2), (i, j + 3)]
    elif p == 'D':
        return [(i, j), (i + 1, j - 1), (i + 1, j), (i + 2, j - 1)]
    elif p == 'E':
        return [(i, j), (i, j + 1), (i + 1, j + 1), (i + 1, j + 2)]
    elif p == 'F':
        return [(i, j), (i + 1, j), (i + 1, j + 1), (i + 2, j + 1)]
    elif p == 'G':
        return [(i, j), (i, j + 1), (i + 1, j - 1), (i + 1, j)]
    else:
        return None


def check_pattern(data, block):
    for p in block:
        if is_out_of_bounds(p[0], p[1]) or (data[p[0]][p[1]] == '0'):
            return False

    return True


def is_out_of_bounds(x, y):
    if x < 0 or x >= 8 or y < 0 or y >= 8:
        return True
    else:
        return False


main()

Submission status: Accepted

Solution code:
while True:
    try:
        h = 0
        a=["","","",""]
        for i in range(8):
            tmp = raw_input()
            if int(tmp) != 0:
                a[h] = tmp
                h += 1
    	if h == 1:
            print "C"
        elif h == 2:
            c = a[0].index("1") - a[1].index("1")
            if c == 0:
                print "A"
            elif c == -1:
                print "E"
            else:
                print "G"
        elif h == 3:
            c = a[0].index("1") - a[2].index("1")
            print "D" if c == 1 else "F"
        else:
            print "B"
    	raw_input()
    except:
	break

Submission status: Accepted

Solution code:
import sys
ptn = [18,48,6,30,20,34,16]

def f(D):
    i = 0
    s = 0
    D = D[D.index("1"):]
    for c in D:
        if c=="1": s += i
        i += 1
    p = "ABCDEFG"[ptn.index(s)]
    return p

i=0
D=""
for s in sys.stdin:
    if i<8:
        i+=1
        D+=s[:-1]
    else:
        print f(D)
        i=0
        D=""
print f(D)

Submission status: Accepted

Solution code:
a = [
    ['11', '11'],
    ['1', '1', '1', '1'],
    ['1111'],
    ['01', '11', '10'],
    ['110', '011'],
    ['10', '11', '01'],
    ['011', '110']
]


def f(b):
    for j in range(len(a)):
        for x in range(9 - len(a[j][0])):
            for y in range(9 - len(a[j])):
                c = True
                for i in range(len(a[j])):
                    if b[y + i][x:x + len(a[j][0])] != a[j][i]:
                        c = False
                if c:
                    return j

try:
    while True:
        b = [raw_input() for i in range(8)]
        print chr(ord('A') + f(b))
        raw_input()
except:
    pass

Submission status: Accepted

Solution code:
blocks = {'A': [[0, 0, 1, 1],
                [0, 1, 0, 1]],
          'B': [[0, 0, 0, 0],
                [0, 1, 2, 3]],
          'C': [[0, 1, 2, 3],
                [0, 0, 0, 0]],
          'D': [[0, 0, -1, -1],
                [0, 1, 1, 2]],
          'E': [[0, 1, 1, 2],
                [0, 0, 1, 1]],
          'F': [[0, 0, 1, 1],
                [0, 1, 1, 2]],
          'G': [[-1, 0, 0, 1],
                [1, 0, 1, 0]], }

while 1:
    field = []
    for i in xrange(8):
        field.append(raw_input())
    for i in xrange(8):
        for j in xrange(8):
            if field[i][j] == '1':
                for block in blocks:
                    dx, dy = blocks[block]
                    for k in xrange(4):
                        ny = i + dy[k]
                        nx = j + dx[k]
                        if nx < 0 or ny < 0 or nx >= 8 or ny >= 8:
                            break
                        if field[ny][nx] != '1':
                            break
                    else:
                        print block
                        break
    try:
        raw_input()
    except EOFError:
        break

Submission status: Accepted

Solution code:
d = {
        ((0, 0), (1, 0), (0, 1), (1, 1))  : 'A',
        ((0, 0), (0, 1), (0, 2), (0, 3))  : 'B',
        ((0, 0), (1, 0), (2, 0), (3, 0))  : 'C',
        ((0, 0), (-1, 1), (0, 1), (-1, 2)): 'D',
        ((0, 0), (1, 0), (1, 1), (2, 1))  : 'E',
        ((0, 0), (0, 1), (1, 1), (1, 2))  : 'F',
        ((0, 0), (1, 0), (-1, 1), (0, 1)) : 'G'
    }


n = 9
while True:
    if n == 9:
        n = 0
        a = []
    try:
        line = input()
    except:
        break
    a.append(line)
    n += 1
    if n != 8: continue

    piece = [(x, y) for y in range(8) for x in range(8) if a[y][x] == '1']
    x0, y0 = piece[0]
    piece = tuple([(x - x0, y - y0) for x, y in piece])
    print(d[piece])

Submission status: Accepted

Solution code:
while True:
    try:
        mat = []
        for i in range(8):
            tmplst = list(input())
            mat.append(tmplst)
        
        a = []

        for j in mat:
            for k, num in enumerate(j):
                if num == '1':
                    a.append(k)

        if a[1] == a[0] +1:
            if a[2] == a[0] -1:
                print("G")
            elif a[2] == a[0]:
                print("A")
            elif a[2] == a[0] +1:
                print("E")
            else:
                print("C")

        else:
            if a[0] == a[3] +1:
                print("D")
            elif a[0] == a[3]:
                print("B")
            else:
                print("F")

        k = input()
    except EOFError:
        break

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
write = sys.stdout.write
B = [771, 16843009, 15, 66306, 1539, 131841, 774]
C = "ABCDEFG"
def solve():
    N = 8
    su = 0
    for i in range(N):
        s = readline().strip()
        for j in range(N):
            if s[j] == '1':
                su |= 1 << (i*N + j)
    for i in range(N*N):
        for k in range(7):
            b = B[k] << i
            if (su & b) == b:
                write("%s\n" % C[k])
    return True
try:
    while solve():
        readline()
except:
    ...

Submission status: Accepted

Solution code:
while True:
    try:
        board=[[0 for i in range(14)],[0 for i in range(14)],[0 for i in range(14)]]
        for i in range(8):
            row=[0,0,0]+[int(j) for j in input()]+[0,0,0]
            board.append(row)
        board.append([0 for i in range(14)])
        board.append([0 for i in range(14)])
        board.append([0 for i in range(14)])

        for i in range(3,11):
            for j in range(3,11):
                if board[i][j]==0:
                    continue

                if board[i][j]==1 and board[i+1][j]==1 and board[i][j+1]==1 and board[i+1][j+1]==1:
                    block="A"
                elif board[i][j]==1 and board[i+1][j]==1 and board[i+2][j]==1 and board[i+3][j]==1:
                    block="B"
                elif board[i][j]==1 and board[i][j+1]==1 and board[i][j+2]==1 and board[i][j+3]==1:
                    block="C"
                elif board[i][j]==1 and board[i+1][j]==1 and board[i+1][j-1]==1 and board[i+2][j-1]==1:
                    block="D"
                elif board[i][j]==1 and board[i][j+1]==1 and board[i+1][j+1]==1 and board[i+1][j+2]==1:
                    block="E"
                elif board[i][j]==1 and board[i+1][j]==1 and board[i+1][j+1]==1 and board[i+2][j+1]==1:
                    block="F"
                elif board[i][j]==1 and board[i][j+1]==1 and board[i+1][j-1]==1 and board[i+1][j]==1:
                    block="G"
        print(block)
        input()


    except EOFError:
        break

Submission status: Accepted

Solution code:
# 参考 http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2973729#1

def ans(sr, sc, tbl):
	if 4 in sr: return 'C'
	if 4 in sc: return 'B'
	if 1 in sr: return 'F' if tbl[sr.index(1)][sc.index(2)] == 1 else 'D'
	if 1 in sc: return 'E' if tbl[sr.index(2)][sc.index(1)] == 1 else 'G'
	return 'A'
	
tbl = [[] for i in range(8)]
sr, sc = [0]*8, [0]*8
while True:
	for r in range(8): tbl[r] = list(map(int, input()))
	# 行の総数
	for i in range(8): sr[i] = sum(tbl[i])
	# 列の総数
	for i in range(8): sc[i] = sum([tbl[r][i] for r in range(8)])
	print(ans(sr, sc, tbl))
	try: input()
	except: break

Submission status: Accepted

Solution code:
while True:
  data = [[0 for _ in range(8)] for _ in range(8)]
  for i in range(8):
    data_in = input()
    for j in range(8):
      data[i][j] = int(data_in[j])
  block = []
  for i in range(8):
    for j in range(8):
      if data[i][j] == 1:
        block.append([i,j])
  piv_x = block[0][0]
  piv_y = block[0][1]
  if block[3][0] == piv_x + 1 and block[3][1] == piv_y + 1:
    print("A")
  elif block[3][0] == piv_x + 3:
    print("B")
  elif block[3][1] == piv_y + 3:
    print("C")
  elif block[3][1] == piv_y - 1 and block[3][0] == piv_x + 2:
    print("D")
  elif block[3][1] == piv_y + 2 and block[3][0] == piv_x + 1:
    print("E")
  elif block[3][1] == piv_y + 1 and block[3][0] == piv_x + 2:
    print("F")
  elif block[3][1] == piv_y and block[3][0] == piv_x + 1:
    print("G")
  try:
    data_in = input()
  except EOFError:
    break

Submission status: Accepted

Solution code:
if __name__ == '__main__':

	while True:
		try:
			A = []

			for i in range(8):
				tmp = list(map(int,input()))
				if tmp.count(1) > 0:
					A.append(tmp)

			if len(A) == 1:
				print("C")
			elif len(A) == 4:
				print("B")
			else:
				if len(A) == 2:#A,E,G
					if A[0].index(1) < A[1].index(1):
						print("E")
					elif A[0].index(1) > A[1].index(1):
						print("G")
					else:
						print("A")
				elif len(A) == 3:#D,F
					if A[0].index(1) < A[2].index(1):
						print("F")
					else:
						print("D")
			input()

		except EOFError:
			break

Submission status: Accepted

Solution code:
from functools import lru_cache

@lru_cache(maxsize=None) 
def check(data):   
        if A in data:
                print("A")
        elif B in data:
                print("B")
        elif C in data:
                print("C")
        elif D in data:
                print("D")
        elif E in data:
                print("E")
        elif F in data:
                print("F")
        elif G in data:
                print("G")
                

A = '1'*2 + '0'*6 +'1'*2
B = '1' + '0'*7 + '1' + '0'*7 + '1' + '0'*7 + '1'
C = '1'*4
D = '1' + '0'*6 +'1'*2 + '0'*6 +'1'
E = '1'*2 + '0'*7 + '1'*2
F = '1' + '0'*7 + '1'*2 + '0'*7 +'1'
G = '1'*2 + '0'*5 +'1'*2

while True: 
        data = ''.join(map(lambda x: input(), range(8)))
        check(data)
        try: input()
        except: break

Submission status: Accepted

Solution code:
A=[[0,0],[1,0],[0,1],[1,1]]
B=[[0,0],[0,1],[0,2],[0,3]]
C=[[0,0],[1,0],[2,0],[3,0]]
D=[[0,0],[-1,1],[0,1],[-1,2]]
E=[[0,0],[1,0],[1,1],[2,1]]
F=[[0,0],[0,1],[1,1],[1,2]]
G=[[0,0],[1,0],[-1,1],[0,1]]
humen=[]
gentenx="0"
genteny="0"
kigou=[]
ans=[]
s=""
while(1):
    
    
    if len(humen)>=8:
        for y in range(0,8):#y
            for x in range(0,8):#x
                if humen[y][x]=="1" and gentenx=="0" and genteny=="0":#位置記憶
                    gentenx=x
                    genteny=y
                    kigou.append([0,0])
                elif humen[y][x]=="1" :
                    kigou.append([x-gentenx,y-genteny])
        if A==kigou:ans.append("A")
        if B==kigou:ans.append("B")
        if C==kigou:ans.append("C")
        if D==kigou:ans.append("D")
        if E==kigou:ans.append("E")
        if F==kigou:ans.append("F")
        if G==kigou:ans.append("G")
        kigou=[]
        humen=[]
        gentenx="0"
        genteny="0"
    try: s=str(input(""))
    except:break
    if s!="":humen.append(list(s))

for i in ans:
    print(i)

Submission status: Accepted

Solution code:
while 1:
    try:
        n=[]
        for i in range(8):
            s=input()
            n_s=[]
            for j in s:
                n_s.append(int(j))
            for j in range(3):n_s.append(0)
            n.append(n_s)
        n_s=[0]*11
        for i in range(3):
            n.append(n_s)    
        for i in range(64):
            if n[i//8][i%8]==1:
                break
        p_x=i//8
        p_y=i%8
        if n[p_x][p_y]+n[p_x][p_y+1]+n[p_x+1][p_y]+n[p_x+1][p_y+1]==4:print("A")
        elif n[p_x][p_y]+n[p_x+1][p_y]+n[p_x+2][p_y]+n[p_x+3][p_y]==4:print("B")
        elif n[p_x][p_y]+n[p_x][p_y+1]+n[p_x][p_y+2]+n[p_x][p_y+3]==4:print("C")
        elif n[p_x][p_y]+n[p_x][p_y+1]+n[p_x+1][p_y+1]+n[p_x+1][p_y+2]==4:print("E")
        elif n[p_x][p_y]+n[p_x+1][p_y]+n[p_x+1][p_y+1]+n[p_x+2][p_y+1]==4:print("F")
        else:
            if n[p_x][p_y]+n[p_x+1][p_y-1]+n[p_x+1][p_y]+n[p_x+2][p_y-1]==4:print("D")
            elif n[p_x][p_y]+n[p_x][p_y+1]+n[p_x+1][p_y-1]+n[p_x+1][p_y]==4:print("G")
        s=input()
    except:break

Submission status: Accepted

Solution code:
cont = 1
while(cont):
    a = []
    for i in range(8):
        a.append([int(i) for i in list(input())])
    try:
        _ = input()
    except EOFError:
        cont = 0
    ret = 1
    for i in range(8):
        if ret == 0:
            break
        for j in range(8):
            if ret == 0:
                break
            if a[i][j] == 1:
                ret = 0
                if j+1 < 8 and a[i][j+1] == 1:
                    if j+2 < 8 and a[i][j+2] == 1:
                        print("C")
                    else:
                        if j+2 < 8 and i+1 < 8 and a[i+1][j+2] == 1:
                            print("E")
                        elif i+1 < 8 and a[i+1][j+1] == 1:
                            print("A")
                        else:
                            print("G")
                else:
                    if i+1 < 8 and a[i+1][j] == 1:
                        if i+2 < 8 and a[i+2][j] == 1:
                            print("B")
                        else:
                            if j+1 < 8 and a[i+1][j+1] == 1:
                                print("F")
                            else:
                                print("D")

Submission status: Accepted

Solution code:
import sys
 
counter = 0
block = []
for line in sys.stdin:
  if line == "\n":
    counter = -1
    block = []
  else:
    counter += 1
    for i in line:
      if i == "1":
        block.append([counter,line.index(i)])
  if counter == 7:
    if block[0][0] == block[1][0]:
      if block[1][0] == block[2][0]:
        print("C")
      elif block[0][1] == block[2][1]:
        print("A")
      elif block[0][1] < block[2][1]:
        print("E")
      else:
        print("G")
    else:
      if block[0][1] == block[3][1]:
        print("B")
      elif block[0][1] < block[3][1]:
        print("F")
      else:
        print("D")

Submission status: Accepted

Solution code:
while True:
  vv = []
  for i in range(8):
    v = [int(e) for e in list(input())]
    vv.append(v)
  for index in reversed(range(len(vv))):
    t = all(x == 0 for x in vv[index])
    #print(t)
    if t == True:
      vv.pop(index)
  height = len(vv)
  for i in reversed(range(len(vv[0]))):
    aa = [vv[h][i] for h in range(height)]
    aa = all([ a==0 for a in aa ])
    if aa == True:
      for h in range(height): 
        del vv[h][i]
  #  print(aa)
  #print(vv)
  obj = { 'A': [[1, 1], [1, 1]] ,
  'B': [[1], [1], [1], [1]],
  'C': [[1, 1, 1, 1]],
  'D': [[0,1],[1,1],[1,0]] ,
  'E': [[1,1,0],[0,1,1]], 
  'F': [[1,0], [1,1], [0,1]], 
  'G': [[0,1,1], [1,1,0]] } 
  #print(obj)
  for k, v in obj.items():
    if v == vv:
      print(k)
      break
  try:
    input()
  except:
    break

Submission status: Accepted

Solution code:
def solve():
    line = input()
    while True:
        surface = list(map(int, line))
        for _ in range(7):
            surface.extend(map(int, input()))
        
        for i, v in enumerate(surface):
            if not v == 1:
                continue
            
            # A
            if i+9 < 64 and surface[i+1] == 1 and surface[i+8] == 1 and surface[i+9] == 1:
                print('A')
                break
            
            # B
            if i+24 < 64 and surface[i+24] == 1:
                print('B')
                break
            
            # C
            if surface[i+3] == 1:
                print('C')
                break
            
            # D
            if i+15 < 64 and surface[i+15] == 1:
                print('D')
                break
            
            # E
            if i+10 < 64 and surface[i+10] == 1:
                print('E')
                break
            
            # F
            if i+17 < 64 and surface[i+17] == 1:
                print('F')
                break
            
            # G
            if surface[i+1] == 1 and surface[i+7] == 1 and surface[i+8] == 1:
                print('G')
                break
            
        
        try:
            input()
            line = input()
        except EOFError:
            break
    

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
while True:
    input_line = raw_input()
    if input_line:
        yoko = [int(char) for char in input_line]
        mapppp.append(yoko)
    else:
        for XXX in lis:
            flag = False
            for xxx, pattern in XXX.items():
                if university(xxx, pattern):
                    flag = True
                    break
            if flag == True:
                break

Submission status: Runtime Error

Solution code:
def university(xxx, pattern):
    tate = 0
    yoko = 1
    for current_tate in range(8-xxx[tate]+1):
        for current_yoko in range(8-xxx[yoko]+1):
            if absolutely_fantastic(current_tate, current_yoko):
                return True

def absolutely_fantastic(current_tate, current_yoko):
    tate = 0
    yoko = 1
    run = []
    for add_tate in range(xxx[tate]):
        for add_yoko in range(xxx[yoko]):
            run.append(mapppp[current_tate+add_tate][current_yoko+add_yoko])
    if run == pattern:
        print xxx[2]
        return True

A = {(2,2,'A'):[1,1,1,1]}
B = {(4,1,'B'):[1,1,1,1]}
C = {(1,4,'C'):[1,1,1,1]}
D = {(3,2,'D'):[0,1,1,1,1,0]}
E = {(2,3,'E'):[1,1,0,0,1,1]}
F = {(3,2,'F'):[1,0,1,1,0,1]}
G = {(2,3,'G'):[0,1,1,1,1,0]}
lis = [A,B,C,D,E,F,G]
mapppp = []
while True:
    for i in range(8):
        input_line = raw_input()
        yoko = [int(char) for char in input_line]
        mapppp.append(yoko)
    for XXX in lis:
        flag = False
        for xxx, pattern in XXX.items():
            if university(xxx, pattern):
                flag = True
                break
        if flag == True:
            break
    raw_input()

Submission status: Runtime Error

Solution code:
import sys

for s in sys.stdin:
	sur = [list(map(int, s.strip()))]
	if 1 not in sur[0]:
		sur.pop()
	for _ in range(7):
		sur.append(list(map(int, input().strip())))
		if 1 not in sur[-1]:
			sur.pop()

	if len(sur) == 1:
		print("C")
	elif len(sur) == 2:
		if sur[0].index(1) == sur[1].index(1):
			print("A")
		elif sur[0].index(1) < sur[1].index(1):
			print("E")
		else:
			print("G")
	elif len(sur) == 3:
		if sur[0].index(1) > sur[2].index(1):
			print("D")
		else:
			print("F")
	elif len(sur) == 4:
		print("B")

Submission status: Runtime Error

Solution code:
while True:
	try:
		code = [raw_input() for _ in range(8)]
	except EOFError:
		break
	
	code = "".join(code)
	
	check = 0
	for var in range(0, len(code)):
		if int(code[var:var+1]) == 1:
			check = var
			break
	
	if int(code[check+1:check+2]) == 1 and int(code[check+8:check+9]) == 1:
			if int(code[check+9:check+10]) == 1:
				print "A"
			if int(code[check+7:check+8]) == 1:
				print "G"
	elif int(code[check+1:check+2]) == 1:
		if int(code[check+2:check+3]) == 1 and int(code[check+3:check+4]) == 1:
			print "C"
		if int(code[check+9:check+10]) == 1 and int(code[check+10:check+11]) == 1:
			print "E"
	elif int(code[check+8:check+9]) == 1:
		if int(code[check+16:check+17]) == 1 and int(code[check+24:check+25]) == 1:
			print "B"
		if int(code[check+7:check+8]) == 1 and int(code[check+15:check+16]) == 1:
			print "D"
		if int(code[check+9:check+10]) == 1 and int(code[check+17:check+18]) == 1:
			print "F"

Submission status: Runtime Error

Solution code:
while True:
	try:
		code = [raw_input() for _ in range(8)]
	except EOFError:
		break
	
	code = "".join(code)
	
	str(code)
	check = 0
	for var in range(0, len(code)):
		if int(code[var:var+1]) == 1:
			check = var
			break
	
	if int(code[check+1:check+2]) == 1 and int(code[check+8:check+9]) == 1:
			if int(code[check+9:check+10]) == 1:
				print "A"
			if int(code[check+7:check+8]) == 1:
				print "G"
	elif int(code[check+1:check+2]) == 1:
		if int(code[check+2:check+3]) == 1 and int(code[check+3:check+4]) == 1:
			print "C"
		if int(code[check+9:check+10]) == 1 and int(code[check+10:check+11]) == 1:
			print "E"
	elif int(code[check+8:check+9]) == 1:
		if int(code[check+16:check+17]) == 1 and int(code[check+24:check+25]) == 1:
			print "B"
		if int(code[check+7:check+8]) == 1 and int(code[check+15:check+16]) == 1:
			print "D"
		if int(code[check+9:check+10]) == 1 and int(code[check+17:check+18]) == 1:
			print "F"

Submission status: Runtime Error

Solution code:
from math import *
PI = 3.1415926535898
pool = []
pool.append("1100000011")
pool.append("1000000010000000100000001")
pool.append("1111")
pool.append("1000000110000001")
pool.append("11000000011")
pool.append("100000001100000001")
pool.append("110000011")
while True:
	try:
		pat = ""
		for i in range(8):
			pat += str(raw_input())
		flag = False
		tp = ""
		for x in pat:
			if x != '0':
				flag = True
			if flag:
				tp += x
		pat = reversed(tp)
		flag = False
		tp = ""
		for x in pat:
			if x != '0':
				flag = True
			if flag:
				tp += x
		pat = tp
		print chr(pool.index(pat) + ord('A'))
	except EOFError:
		break

Submission status: Runtime Error

Solution code:
ans = ['A','B','C','D','E','F','G']
def get(x):
    for i in range(8):
        for j in range(8):
            if i < 7 and j < 7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1':
                    return 0
            if i<5:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+2][j]=='1' and x[i+3][j]=='1':
                    return 1
            if j<5:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i][j+2]=='1' and x[i][j+3]=='1':
                    return 2
            if i<6 and 0<j:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1' and x[i+2][j-1]=='1':
                    return 3
            if i<7 and j<6:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j+1]=='1' and x[i+1][j+2]=='1':
                    return 4
            if i<6 and j<7:
                if x[i][j]=='1' and x[i+1][j]=='1' and x[i+1][j+1]=='1' and x[i+2][j+1]=='1':
                    return 5
            if i<7 and 0<j<7:
                if x[i][j]=='1' and x[i][j+1]=='1' and x[i+1][j]=='1' and x[i+1][j-1]=='1':
                    return 6
while 1:
    l = []
    for i in range(8):
        l.append(raw_input())
    print ans[get(l)]
    raw_input()

Submission status: Runtime Error

Solution code:
import sys
s=[]
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
#for line in sys.stdin:
	if line!="":
		s.append(line)
	else:
		while s[0]=="00000000":
			del s[0]
		while s[len(s)-1]=="00000000":
			del s[len(s)-1]
		i=0
		while i<len(s[0]):
			print i
			for l in s:
				if l[i]=="1"
					break
			else:
				for l in range(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])

Submission status: Runtime Error

Solution code:
import sys
s=[]
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
cnt=0
for line in sys.stdin:
	cnt+=1
	if line=="":
		continue
	if cnt<8:
		s.append(line)
	else:
		cnt=0
		while s[0]=="00000000":
			del s[0]
		while s[len(s)-1]=="00000000":
			del s[len(s)-1]
		i=0
		while i<len(s[0]):
			for l in s:
				if l[i]=="1":
					break
			else:
				for l in range(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])

Submission status: Runtime Error

Solution code:
import sys
s=[]
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
cnt=0
for line in sys.stdin:
	if line=="":
		continue
	cnt+=1
	if cnt<8:
		s.append(line)
	else:
		cnt=0
		while s[0]=="00000000":
			del s[0]
		while s[len(s)-1]=="00000000":
			del s[len(s)-1]
		i=0
		while i<len(s[0]):
			for l in s:
				if l[i]=="1":
					break
			else:
				for l in range(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])

Submission status: Runtime Error

Solution code:
import sys
s=[]
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
cnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	cnt+=1
	if cnt<8:
		s.append(line.rstrip('\n'))
	else:
		cnt=0
		while s[0]=="00000000":
			del s[0]
		while s[len(s)-1]=="00000000":
			del s[len(s)-1]
		i=0
		while i<len(s[0]):
			for l in s:
				if l[i]=="1":
					break
			else:
				for l in range(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])

Submission status: Runtime Error

Solution code:
import sys
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
s=[]
linecnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	linecnt+=1
	if linecnt<8:
		s.append(line.rstrip("\n"))
	else:
		while s[0]=="00000000":
			del(s[0])
		while s[len(s)-1]=="00000000":
			del(s[len(s)-1])
		i=0
		while i<len(s[0]):
			for l in xrange(len(s)):
				if s[l][i]=="1":
					break
			else:
				for l in xrange(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
				i-=1
			i+=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])
		linecnt=0

Submission status: Runtime Error

Solution code:
import sys
dic={"A":["11","11"],"B":["1","1","1","1"],"C":["1111"],"D":["01","11","10"],
		"E":["110","011"],"F":["10","11","01"],"G":["011","110"]}
s=[]
linecnt=0
for line in sys.stdin:
	if line=="\n" or line=="":
		continue
	linecnt+=1
	if linecnt<8:
		s.append(line.rstrip("\n"))
	else:
		while s[0]=="00000000":
			del(s[0])
		while s[len(s)-1]=="00000000":
			del(s[len(s)-1])
		i=len(s[0])-1
		while i>=0:
			for l in xrange(len(s)):
				if s[l][i]=="1":
					break
			else:
				for l in xrange(len(s)):
					s[l]=s[l][0:i]+s[l][i+1:len(s[l])]
			i-=1
		for d in dic.keys():
			if dic[d]==s:
				print d
				break
		while len(s)>0:
			del(s[0])
		linecnt=0

Submission status: Runtime Error

Solution code:
while True:
    try:
        Map = []
        Base = []
        End = []
        for i in range(8):
            Map.append(list(map(str,input())))
        for i in range(8):
            if Base == []:
                
                for j in range(8):
                    if Map[i][j] == '1':
                        Base = [j,i]
                        break
            else:
                break
        for i in range(7,-1,-1):
            if End == []:
                for j in range(7,-1,-1):
                    if Map[i][j] == '1':
                        End = [j,i]
                        break
            else:
                break
        Yoko = End[0] - Base[0]
        Tate = End[1] - Base[1]
        if Tate == 1 and Yoko == 1:
            print("A")
        elif Yoko == 0 and Tate == 3:
            print("B")
        elif Tate == 0 and Yoko == 3:
            print("C")
        elif Yoko == -1 and Tate == 2:
            print("D")
        elif Yoko == 2 and Tate == 1:
            print("E")
        elif Yoko == 1 and Tate == 2:
            print("F")
        elif Tate == 1 and Yoko == 0:
            print("G")
            
            
    except EOFError:
        break