import re
# 패턴 넣으면 정규표현식 이용해서 해당하는 것 리스트로 리턴(find)
def match_dna_list(pattern_s, content_s):
pattern_s_r = pattern_s.replace('_', '.')
# pattern_s_r='(?=(.A....))'
pattern_s_r = '(?=(' + pattern_s_r + '))'
find = re.findall(pattern_s_r,content_s)
#print(find)
return find
with open ('3.inp','r') as f:
#.strip()을 해줘야 \n 이 없어짐
# \n 이 있으면 완전 다른 문자가 되기 때문에 findall()하면 안 나옴
pattern = f.readline().strip()
# 나머지부분 읽음
dna_seq=''
for i in f:
dna_seq += i.strip()
with open('dna.out', 'w') as f2:
# find 안에 값이 있다면
if ( match_dna_list(pattern,dna_seq) ):
f2.write('\n'.join(match_dna_list(pattern,dna_seq)))
else:
f2.write('No')
# box1의 a점(ax,ay), box1의 b점(bx,by)
ax,ay=0,0
bx,by=0,0
# box2의 c점, d점
cx,cy=0,0
dx,dy=0,0
def point(ax,ay,bx,by,cx,cy,dx,dy):
if((ax,ay)==(dx,dy) or (bx,by)==(cx,cy) or (bx,ay)==(cx,dy) or (ax,by)==(dx,cy)) :
return True
else:
return False
def line(ax,ay,bx,by,cx,cy,dx,dy):
# 꼭짓점 하나 일치
if(((bx,by)==(cx,dy) and by>cy) or (((bx,ay)==(cx,cy) and dy>ay))
or((dx,cy)==(ax,ay) and by>cy) or ((dx,dy)==(ax,by) and dy>ay)
# 변 일치
or ((bx,by)==(cx,dy) and (bx,ay)==(cx,cy)) or ((ax,ay)==(dx,cy) and (dx,dy)==(ax,by))
or ((cx, cy) == (ax, by) and (bx, by) == (dx, cy)) or ((ax, ay) == (cx, dy) and (dx, dy) == (bx, ay))
# 그 사이(a,b의 한 변에 c,d가 겹침)
or (ax==dx and (ay<cy<by or ay<dy<by)) or (bx==cx and (ay<cy<by or ay<dy<by))
or (by==cy and (ax<cx<bx or ax<dx<bx)) or (ay==dy and (ax<cx<bx or ax<dx<bx))
# 그 사이(c,d의 한 변에 a,b가 겹침)
or (ax == dx and (cy < ay < dy or cy < by < dy)) or (bx == cx and (cy < ay < dy or cy < by < dy))
or (by == cy and (cx < ax < dx or cx < bx < dx)) or (ay == dy and (cx < ax < dx or cx < bx < dx))
# 내부 한 변 일치(ab안에 cd)
# or (ay==cy and ax<cx<bx and ax<dx<bx and ay<dy<by) or (ax==cx and ay<cy<by and ay<dy<by and ax<dx<bx)
# or (by==dy and ax<cx<bx and ax<dx<bx and ay<cy<by) or (bx==dx and ay<cy<by and ay<dy<by and ax<cx<bx)
# 내부 한 변 일치(cd안에 ab)
# or (ay==cy and cx<ax<dx and cx<bx<dx and cy<by<dy) or (ax==cx and cy<ay<dy and cy<by<dy and cx<bx<dx)
# or (by==dy and cx<ax<dx and cx<bx<dx and cy<ay<dy) or (bx==dx and cy<ay<dy and cy<by<dy and cx<ax<dx)
):
return True
else:
return False
def null(ax,ay,bx,by,cx,cy,dx,dy): #cy>by or ay>dy
#dx<ax or bx<cx or min(cy,dy)>max(ay,by) or min(ay,by)>max(cy,dy)
#우,좌,상,하 바깥에서 안 접할 때
if(bx<cx or dx<ax or by<cy or dy<ay):
return True
#안에서 안 접할 때
elif(bx-ax<dx-cx and by-ay<dy-cy and (cx<ax<dx and cx<bx<dx) and (cy<ay<dy and cy<by<dy)): #속에 들어감
return True
elif(bx-ax>dx-cx and by-ay>dy-cy and (ax<cx<bx and ax<dx<bx) and (ay<cy<by and ay<dy<by)): #속에 들어감
return True
else:
return False
# main 함수
ax,ay,bx,by=map(int,input().split())
cx,cy,dx,dy=map(int,input().split())
if(line(ax,ay,bx,by,cx,cy,dx,dy)):
print('LINE')
elif (point(ax,ay,bx,by,cx,cy,dx,dy)):
print('POINT')
elif(null(ax,ay,bx,by,cx,cy,dx,dy)):
print('NULL')
else:
print('FACE')
#(r,c)가 편해서 백준과 반대로 받음
#변수는 내 맘대로받는거니깐
r,c=map(int,input().split())
idx=int(input())
# 답 찾는 함수
def find_ans(p):
if(p>r*c): #out of range
print(0)
for i in range(r):
for j in range(c):
if(arr[i][j]==p):
print(i+1,j+1)
# 배정 된 표 만들기
arr=[[0 for _ in range(c)]for _ in range(r)]
x,y=0,-1
num=1 #넣을 번호
add=1 #1 or -1
for i in range(c,0,-1):
j=i+(r-c-1)
for _ in range(i):
y+= add
arr[x][y] = num
num+=1
for _ in range(j):
x+=add
arr[x][y]=num
num+=1
add*=-1 #방향 바꿈
find_ans(idx)