Last time I have ABC today, so I only have one question.
#41 Problem
** Thoughts ** This is a problem that I have been struggling with for a long time. When I solved it this time, I didn't understand why I was struggling. Since the range of the solution is small, check all with for. I put a flag to check if M conditions are met.
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]
for i in range(10**n):
i = str(i)
flag = True
if len(i) == n:
for j in range(m):
if i[sc[j][0]-1] != str(sc[j][1]):
flag = False
if flag:
print(i)
quit()
print(-1)
I will do my best for ABC today. I want to turn brown quickly. see you.
Recommended Posts