# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ!!
import re
input_line = input()
page_list = []
query_count = int(input_line)
empty = ''
for i in range(0,query_count):
input_ = input()
if re.match("^go to",input_) :
page = re.match("(?:go to )(.{0,})$",input_)[1]
empty = page
page_list.append(page)
else:
page_list.pop()
print(page_list[len(page_list) - 1])
# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ!!
input_line = input()
input_list =input_line.split()
# print(input_list)
h = int(input_list[0])
w = int(input_list[1])
k = int(input_list[2])+1
list1 = list()
for i in range(0,h):
row = list(input())
list1.append(row)
# print(list1)
n = 'N'
nx = 0;
ny = 0;
for index, lst in enumerate(list1):
if n in lst:
nx = index
ny = lst.index(str(n))
list_index = dict()
for i in range(1,k):
for index, lst in enumerate(list1):
if str(i) in lst:
x = index
y = lst.index(str(i))
list_index[i] = [x,y]
# print(list_index)
output_list = list()
kake = 5000
for i in list(list_index):
# print(list_index[i][0])
x = list_index[i][0]
y = list_index[i][1]
sum1 = abs(nx-x) + abs(ny-y)
# print(sum1)
if kake > sum1:
kake = sum1
output_list = list()
output_list.append(i)
elif kake == sum1:
output_list.append(i)
else:
continue
output_list.sort()
print(len(output_list))
for i in output_list:
print(i)
반응형
댓글