Problem:


Score : 200 points

Problem Statement

There are N students and M checkpoints on the xy-plane.

The coordinates of the i-th student (1 \leq i \leq N) is (a_i,b_i), and the coordinates of the checkpoint numbered j (1 \leq j \leq M) is (c_j,d_j).

When the teacher gives a signal, each student has to go to the nearest checkpoint measured in Manhattan distance. 

The Manhattan distance between two points (x_1,y_1) and (x_2,y_2) is |x_1-x_2|+|y_1-y_2|.

Here, |x| denotes the absolute value of x.

If there are multiple nearest checkpoints for a student, he/she will select the checkpoint with the smallest index.

Which checkpoint will each student go to?

Constraints

1 \leq N,M \leq 50

-10^8 \leq a_i,b_i,c_j,d_j \leq 10^8

All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
a_1 b_1
:  
a_N b_N
c_1 d_1
:  
c_M d_M

Output

Print N lines.

The i-th line (1 \leq i \leq N) should contain the index of the checkpoint for the i-th student to go.

Sample Input 1

2 2
2 0
0 0
-1 0
1 0

Sample Output 1

2
1

The Manhattan distance between the first student and each checkpoint is:

For checkpoint 1: |2-(-1)|+|0-0|=3

For checkpoint 2: |2-1|+|0-0|=1

The nearest checkpoint is checkpoint 2. Thus, the first line in the output should contain 2.

The Manhattan distance between the second student and each checkpoint is:

For checkpoint 1: |0-(-1)|+|0-0|=1

For checkpoint 2: |0-1|+|0-0|=1

When there are multiple nearest checkpoints, the student will go to the checkpoint with the smallest index. Thus, the second line in the output should contain 1.

Sample Input 2

3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5

Sample Output 2

3
1
2

There can be multiple checkpoints at the same coordinates.

Sample Input 3

5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000

Sample Output 3

5
4
3
2
1



Sample input:
2 2
2 0
0 0
-1 0
1 0


Sample output:
2
1

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
l_n=[list(map(int,input().split())) for _ in range(n)]
l_m=[list(map(int,input().split())) for _ in range(m)]

for i,j in l_n:
    distance=0
    cnt = 0
    ans = float ( "inf" )
    for k,l in enumerate(l_m):
        a,b=l
        distance=(i-a)**2+(j-b)**2
        if ans>distance:
            ans=min(ans,distance)
            cnt=k+1
    print(cnt)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a,b in ab:
    ans = [0,10**8+1]
    for i in range(m):
        c,d = cd[i][0], cd[i][1]
        if abs(a-c) + abs(b-d) < ans[1]:
            ans = [i, abs(a-c) + abs(b-d)]
    print(ans[0]+1)

Submission status: Wrong Answer

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
import sys
n,m = ma()
ckp = []
st = []

for i in range(n):
    st.append(lma())
for i in range(m):
    ckp.append(lma())
for a,b in st:
    tmp=10**15
    ans=0
    for i  in range(m):
        c,d=ckp[i]
        if tmp<abs(a-c)+abs(b-d):
            tmp=abs(a-c)+abs(b-d)
            ans=i+1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=[]
C=[]
for i in range(n):
  a,b=map(int,input().split())
  A.append([a,b])
for j in range(m):
  c,d=map(int,input().split())
  C.append([c,d])
for i in range(n):
  dis=10**8+2
  ans=0
  for j in range(m):
    if abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])<dis:
      dis=abs(A[i][0]-C[j][0])+abs(A[i][1]-C[j][1])
      ans=j+1
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
P = [list(map(int,input().split())) for _ in range(n)]
C = [list(map(int,input().split())) for _ in range(m)]

for i in range(n):
  d = 9999
  t = 0
  for j in range(m):
    dist = abs(P[i][0]-C[j][0]) + abs(P[i][1]-C[j][1])
    if d > dist:
      t = j
      d = dist
  print(t+1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 2 * 10 ** 8
  min_pos = 0
  for j in range(m):  
    dist = md(students[i], targets[j])
    if x > dist:
      x = dist
      min_pos = j + 1
      
    
  print(min_pos)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 2 * 10 ** 8
  for j in range(m):    
    if x >= md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
      
for i in range(n):      
  print(snumber[i][0])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 2 * 10 ** 8 + 1
  for j in range(m):    
    if x > md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
      
for i in range(n):      
  print(snumber[i][0])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]
targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n


def md(s, t):
    d = abs(s[0] - t[0]) + abs(s[1] - t[1])
    return d


for i in range(n):
    x = 2 * 10 ** 8
    for j in range(m):
        if x > md(students[i], targets[j]):
            x = md(students[i], targets[j])
            snumber[i] = (j + 1, md(students[i], targets[j]))

for i in range(n):
    print(snumber[i][0])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students = [list(map(int, input().split())) for i in range(n)]

targets = [list(map(int, input().split())) for i in range(m)]
x = 0
snumber = [(0, x)] * n
  
def md(s, t):
  d = abs(s[0] - t[0]) + abs(s[1] - t[1])
  return d

for i in range(n):
  x = 2 * 10 ** 8
  for j in range(m):    
    if x > md(students[i], targets[j]):
      x = md(students[i], targets[j])
      snumber[i] = (j+1, md(students[i], targets[j]))
 
for i in range(n):      
  print(snumber[i][0])

Submission status: Wrong Answer

Solution code:
# B - Checkpoints
def main():
    n, m = map(int, input().split())
    a_b = [input().split() for i in range(n)]
    c_d = [input().split() for i in range(m)]

    for i in range(m):
        temp = []
        for j in range(n):
            temp.append(abs(int(a_b[j][0])-int(c_d[i][0]))+abs(int(a_b[j][1])-int(c_d[i][1])))
        else:
            print(temp.index(min(temp))+1)


        
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    check_point_dist = 10 ** 8 * 2
    check_point = 0
    count = 0
    for c, d in cd:
        count += 1
        if check_point_dist > abs(a - c) + abs(b - d):
            check_point = count
            check_point_dist = abs(a - c) + abs(b - d)
    else:
        print(check_point)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
place = [list(map(int,input().split())) for _ in range(N)]
check = [list(map(int,input().split())) for _ in range(M)]
for x,y in place:
    tmp = 10**9
    for i in range(M):
        dis = ((x-check[i][0])**2 + (y-check[i][1])**2)**(1/2)
        if tmp > dis:
            tmp = dis
            ans = i+1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
ab=[list(map(int, input().split())) for i in range(n)]
cd=[list(map(int, input().split())) for j in range(m)]

for i in range(n):
    l=[]
    for j in range(m):
        dist=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        l.append(dist)
    print(l)
    goal = l.index(min(l))+1
    print(goal)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = []
cd = []
for i in range(N):
  tmp = list(map(int, input().split()))
  ab.append(tmp)
for j in range(M):
  tmp = list(map(int, input().split()))
  cd.append(tmp)
tmp = 2*(10**8)+2
for i in range(N):
  tmp2 = 0
  for j in range(M):
    if tmp > abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]):
      tmp = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
      tmp2 = j
  print(tmp2+1)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
students = []
points = []
for _ in range(N):
    students.append(list(map(int,input().split())))
for _ in range(M):
    points.append(list(map(int,input().split())))

for i in range(N):
    MIN = 10 ** 8
    index = -1
    for j in range(M):
        if MIN > abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1]):
            MIN = abs(students[i][0] - points[j][0]) + abs(students[i][1] - points[j][1])
            index = j
    print(index + 1)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())
students = []
points = []
for _ in range(N):
    students.append(list(map(int,input().split())))
for _ in range(M):
    points.append(list(map(int,input().split())))

for i in range(N):
    MIN = 10 ** 8
    index = -1
    for j in range(M):
        if MIN > ((students[i][0] - points[j][0]) ** 2 + (students[i][1] - points[j][1]) ** 2) ** 0.5:
            MIN = ((students[i][0] - points[j][0]) ** 2 + (students[i][1] - points[j][1]) ** 2) ** 0.5
            index = j
    print(index + 1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
cd = [tuple(map(int, input().split())) for _ in range(M)]

for a, b in ab:
    tmp_dist = 10 ** 8 * 2
    tmp_point = 0
    count = 0
    for c, d in cd:
        count += 1
        if tmp_dist > abs(a - c) + abs(b - d):
            tmp_point = count
        tmp_dist = min(tmp_dist, abs(a - c) + abs(b - d))
    else:
        print(tmp_point)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [map(int, input().split()) for _ in range(N)]
a, b = zip(*ab)
cd = [map(int, input().split()) for _ in range(M)]
c, d = zip(*cd)

for i in range(N):
    tmp_dist = 10 ** 8 * 2
    tmp_point = 0
    for j in range(M):
        if tmp_dist > abs(a[i] - c[j]) + abs(b[i] - d[j]):
            tmp_point = j + 1
        tmp_dist = min(tmp_dist, abs(a[i] - c[j]) + abs(b[i] - d[j]))
    else:
        print(tmp_point)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [map(int, input().split()) for _ in range(N)]
a, b = zip(*ab)
cd = [map(int, input().split()) for _ in range(M)]
c, d = zip(*cd)

for i in range(N):
    tmp_dist = 10 ** 8
    tmp_point = 0
    for j in range(M):
        if tmp_dist > abs(a[i] - c[j]) + abs(b[i] - d[j]):
            tmp_point = j + 1
        tmp_dist = min(tmp_dist, abs(a[i] - c[j]) + abs(b[i] - d[j]))
        
    else:
        print(tmp_point)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
p = [list(map(int, input().split())) for i in range(n + m)]
for a, b in p[:n]:
  x = [abs(a - c) + abs(b - d) for c, d in p[n:]]
print(x.index(min(x)) + 1)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())

ab=[list(map(int,input().split())) for i in range(N)]
cd=[list(map(int,input().split())) for i in range(M)]

ans=[0 for i in range(N)]
for i in range(N):
    dis=10**6
    for j in range(M):
        xx=abs(ab[i][0]-cd[j][0])
        yy=abs(ab[i][1]-cd[j][1])
        temp=xx+yy
        if dis>temp:
            dis=temp
            ans[i]=j
for a in ans:
    print(a+1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]

closest = {}
for s in student:
    min_dist = 'INF'
    ans = 1
    for c in checkpoint:
        dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if min_dist == 'INF' or dist < min_dist:
            min_dist = dist
            closest[s] = ans
        ans += 1

print(closest[s] for s in student)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(M)]
for i in range(N):
    m = 0
    for j in range(M):
        if abs(s[i][0]-c[m][0]) + abs(s[i][1]-c[m][1]) > abs(s[i][0]-c[j][0]) + abs(s[i][1]-c[j][1]):
            m = j
    print(j+1)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
a, b, c, d = [0] * n, [0] * n, [0] * m, [0] * m
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(m):
    c[i], d[i] = map(int, input().split())

for i in range(n):
    min_dist, min_c = abs(a[0]-c[0]) + abs(b[0]-d[0]), 0
    for j in range(m):
        dist = abs(a[i]-c[j]) + abs(b[i]-d[j])
        if dist < min_dist:
            min_dist = dist
            min_c = j
    print(min_c+1)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
stu=[]
for i in range(N):
  a,b=map(int,input().split())
  stu.append([a,b])
pl=[]
for j in range(M):
  c,d=map(int,input().split())
  pl.append([c,d])
for k in range(N):
  met=2*(10**8)
  pr=0
  for l in range(M):
    if abs(pl[l][0]-stu[k][0])+abs(pl[l][1]-stu[k][1])<met:
      met=abs(pl[l][0]-stu[k][0])+abs(pl[l][1]-stu[k][1])
      pr=l+1
  print(pr)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 2*10**8+100
    ans = 0
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
lsab = []
for i in range(N):
    a,b = map(int,input().split())
    lsab.append([a,b])
lscd = []
for j in range(M):
    c,d= map(int,input().split())
    lscd.append([c,d])

lsans = []
for i in range(N):
    max1 = 2*10**8+1
    ans = 0
    for j in range(M):
        dis = abs(lsab[i][0]-lscd[j][0])+abs(lsab[i][1]-lscd[j][1])
        if dis < max1:
            ans = j+1
            max1 = dis
    lsans.append(ans)

for i in range(N):
    print(lsans[i])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
sts = [list(map(int, input().split())) for i in range(N)]
checkp = [[i+1]+list(map(int, input().split())) for i in range(M)]
rt = [None] * N
distances = [2*(10**8)] * N
for s in range(N):
  for c in checkp:
    dist = abs(sts[s][0]-c[1]) + abs(sts[s][1]-c[2])
    if rt[s] is None:
      rt[s] = c[0]
      distances[s] = dist
    else:
      if distances[s] > dist:
        rt[s] = c[0]
        distances[s] = dist
print(rt)

Submission status: Wrong Answer

Solution code:
def solve():
  N, M = map(int, input().split())
  ans = [0]*N
  A = [0]*N
  B = [0]*N
  for i in range(N):
    A[i],B[i] = map(int, input().split())
  X = [0]*M
  Y = [0]*M
  for i in range(M):
    X[i],Y[i] = map(int, input().split())
  for i in range(N):
    ind = -1
    d_min = float('inf')
    for j in range(M):
      d = ((A[i]-X[j])**2+(B[i]-Y[j])**2)**0.5
      if d<d_min:
        d_min = d
        ind = j+1
    ans[i] = ind
  return ans
print(*solve(),sep='\n')

Submission status: Wrong Answer

Solution code:
MM = input().split()
N = int(MM[0])
M = int(MM[1])
list1 = []
list2 = []
for i in range(N):
  LL = input().split()
  list1.append(LL)
print(list1)
for i in range(M):
  MM = input().split()
  list2.append(MM)
print(list2)
for i in list1:
  mini = 40**8
  ans = 0
  for j in range(len(list2)):
    x = int(i[0]) - int(list2[j][0])
    y = int(i[1]) - int(list2[j][1])
    xx = abs(x) + abs(y)
    if xx < mini:
      mini = xx
      ans = j+1
  print(ans)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
s = [tuple(map(int,input().split())) for _ in range(n)]
c = [tuple(map(int,input().split())) for _ in range(m)]
for i in range(n):
  mini = 0
  m_i = 0
  for j in range(m):
    dis = abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    print(mini, dis)
    if j==0:
      mini, m_i = dis, j+1
      continue
    elif mini > dis:
      mini, m_i = dis, j+1
  print(m_i)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
s = [tuple(map(int,input().split())) for _ in range(n)]
c = [tuple(map(int,input().split())) for _ in range(m)]
for i in range(n):
  mini = 100000001
  m_i = 0
  for j in range(m):
    dis = abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1])
    if mini > dis: mini, m_i = dis, j+1
  print(m_i)

Submission status: Wrong Answer

Solution code:
N,M = map(int, input().split())
S = [list(map(int,input().split())) for _ in range(N)]
C = [list(map(int,input().split())) for _ in range(M)]

for a,b in S:
    distance = 10**10
    ans = 0
    for c,d in C:
        #print(abs(a - c) + abs(b - d))
        if abs(a - c) + abs(b - d) < distance:
            distance = abs(a - c) + abs(b - d)
            ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
N = [list(map(int, input().split())) for _ in range(n)]
M = [list(map(int, input().split())) for _ in range(m)]


for i in range(n):
    ans = 0
    d = 99999999
    for j in range(m):
        tmp = abs(N[i][0]-M[j][0]) + abs(N[i][1]-M[j][1])
        if tmp < d:
            d = tmp
            ans = j
    print(ans+1)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
l = [list(map(int,input().split())) for i in range(n)]
a,b = [list(i) for i in zip(*l)]
l = [list(map(int,input().split())) for i in range(m)]
c,d = [list(i) for i in zip(*l)]

for i in range(n):
    p = 10 ** 8
    t = 50
    for j in range(m):
        e = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if p > e:
            p = e
            t = j + 1
    print(t)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
s,c = [],[]
for i in range(n):
    a = list(map(int,input().split()))
    s.append(a)
for i in range(m):
    a = list(map(int,input().split()))
    c.append(a)


for i in range(n):
    tmp = 10**8
    ans = 0
    for j in range(m):
        b = (abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]))
        if tmp > b:
            tmp = b
            ans = j+1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[list(map(int,input().split())) for i in range(n)]
b=[list(map(int,input().split())) for i in range(m)]
for i in a:
  cnt=2*(10**16)
  ans=0
  for j in range(len(b)):
    if abs(i[0]*b[j][0])+ abs(i[1]*b[j][1])<cnt:
      cnt=abs(i[0]*b[j][0])+ abs(i[1]*b[j][1])
      ans=j+1
  print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())

list_a = []
list_b = []
count = 0
ans = [10**8 for i in range(N)]

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**8
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
            ans[i] = min(count, ans[i])
    print(ans[i])

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())

list_a = []
list_b = []
count = 0

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    ans_x = 10**8
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x:
            ans_x = xxx
            count = j+1
    print(count)

Submission status: Wrong Answer

Solution code:
N, M = map(int,input().split())

list_a = []
list_b = []
ans_x = [10**8 for i in range(N)]
count = 0

for i in range(N):
    a = [int(i) for i in input().split()]
    list_a.append(a)
    
for i in range(M):
    b = [int(i) for i in input().split()]
    list_b.append(b)
    
for i in range(N):
    for j in range(M):
        x = abs(list_a[i][0]-list_b[j][0])
        y = abs(list_a[i][1]-list_b[j][1])
        xxx = x + y
        if xxx < ans_x[i]:
            ans_x[i] = xxx
            count = j+1
    print(count)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]

for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[i+j]+y[i+j])
    
    p.append(l.index(min(l))+1)   
    l=[]
        
for i in range(n):
    print(p[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[i]+y[i])
    
    p.append(l.index(min(l))+1)   
    l=[]
        
for i in range(n):
    print(p[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[i]+y[i])
        p.append(l.index(min(l))+1)
        
    l=[]
        
for i in range(n):
    print(p[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]
for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[i]+y[i])
        p.append(l.index(min(l)))
        l=[]
        
for i in range(n):
    print(p[i])

Submission status: Wrong Answer

Solution code:
N,M = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(N)]

c =[[int(i) for i in input().split()] for j in range(M)]

n = 10000000
n1 = 0
n2 = 0

for i in range(N):
    for j in range(M):
        n1 = abs(c[j][0] - a[i][0]) + abs(c[j][1] - a[i][1])
        if n1 < n:
            n = n1
            n2 = j
    n = 10000000
    print(n2 + 1)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

a = [0]*N
b=[0]*N
c = [0]*M
d =[0]*M

for i in range(N):
    a[i],b[i] = map(int,input().split())
    
    
for i in range(M):
    c[i],d[i] = map(int,input().split())
    
    
for i in range(N):
    x = a[i]
    y = b[i]
    result =0
    Min = 10**20
    
    for j in range(M):
        
        cx = c[j]
        cy = d[j]
        
        temp = abs((cx-x)+(cy-y))
        
        if Min > temp:
            result = j+1
            Min = temp
            
            
    print(result)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 2*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

a = [list(map(int,input().split())) for x in range(N)]
c = [list(map(int,input().split())) for x in range(M)]

min_cpoint = -1
num_stack = 999999

for i in range(N):
    for j in range(M):
        if num_stack > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            num_stack = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_cpoint = j+1
    print(min_cpoint)
    min_cpoint = -1
    num_stack = 9999999

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

a = [list(map(int,input().split())) for x in range(N)]
c = [list(map(int,input().split())) for x in range(M)]

min_cpoint = -1
num_stack = 51

for i in range(N):
    for j in range(M):
        if num_stack > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            num_stack = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_cpoint = j+1
    print(min_cpoint)
    min_cpoint = -1
    num_stack = 51

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())

a = [list(map(int,input().split())) for x in range(N)]
c = [list(map(int,input().split())) for x in range(M)]

min_cpoint = 0
num_stack = 51

for i in range(N):
    for j in range(M):
        if num_stack > abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1]):
            num_stack = abs(a[i][0]-c[j][0]) + abs(a[i][1]-c[j][1])
            min_cpoint = j+1
    print(min_cpoint)
    min_cpoint = 0
    num_stack = 51

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().strip().split()))

# 2次元配列
student = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    student.append(array)

cp = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    cp.append(array)

result = [0] * n
for i in range(n):
  dis_min = 10**9
  for j in range(m):
    dis = abs(student[i][0]-cp[j][0]) + abs(student[i][1] - cp[j][1])
    if dis <= dis_min:
      dis_min = dis
      result[i] = j+1

for i in result:
  print(i)

Submission status: Wrong Answer

Solution code:
n,m = list(map(int,input().strip().split()))

# 2次元配列
student = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    student.append(array)

cp = []
for i in range(m):
    array = list(map(int, input().strip().split()))
    cp.append(array)

result = [0] * n
for i in range(n):
  dis_min = 10**8
  for j in range(m):
    dis = abs(student[i][0]-cp[j][0]) + abs(student[i][1] - cp[j][1])
    if dis < dis_min:
      dis_min = dis
      result[i] = j+1

for i in result:
  print(i)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    a, b = map(int, input().split())
    lista=[]
    for i in range(a):
        c = [int(i) for i in input().split()]
        lista.append(c)

    listb=[]
    for i in range(b):
        c = [int(i) for i in input().split()]
        listb.append(c)

    listc =[]

    for i in lista:
        min = 51*51
        minroot=-1
        for j in range(len(listb)):
            root = abs(i[0] - listb[j][0])  + abs(i[1] - listb[j][1])
            if root <min:
                min =root
                minroot=j+1
        listc.append(minroot)
    for i in listc:
        print(i)

Submission status: Wrong Answer

Solution code:

if __name__ == '__main__':
    a, b = map(int, input().split())
    lista=[]
    for i in range(a):
        c = [int(i) for i in input().split()]
        lista.append(c)

    listb=[]
    for i in range(b):
        c = [int(i) for i in input().split()]
        listb.append(c)

    listc =[]

    for i in lista:
        min = 51*51
        minroot=-1
        for j in range(len(listb)):
            root = (i[0] - listb[j][0])  + (i[1] - listb[j][1])
            if root <min:
                min =root
                minroot=j+1
        listc.append(minroot)
    for i in listc:
        print(i)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a, b = map(int, input().split())
    lista=[]
    for i in range(a):
        c = [int(i) for i in input().split()]
        lista.append(c)

    listb=[]
    for i in range(b):
        c = [int(i) for i in input().split()]
        listb.append(c)

    listc =[]

    for i in lista:
        min = 51*51
        minroot=-1
        for j in range(len(listb)):
            root = (i[0] - listb[j][0]) *(i[0] - listb[j][0])  + (i[1] - listb[j][1])*(i[1] - listb[j][1])
            if root <min:
                min =root
                minroot=j+1
        listc.append(minroot)
    for i in listc:
        print(i)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a, b = map(int, input().split())
    lista=[]
    for i in range(a):
        c = [int(i) for i in input().split()]
        lista.append(c)

    listb=[]
    for i in range(b):
        c = [int(i) for i in input().split()]
        listb.append(c)

    listc =[]

    for i in lista:
        min = 50*50
        minroot=-1
        for j in range(len(listb)):
            root = (i[0] - listb[j][0]) *(i[0] - listb[j][0])  + (i[1] - listb[j][1])*(i[1] - listb[j][1])
            if root <min:
                min =root
                minroot=j+1
        listc.append(minroot)
    for i in listc:
        print(i)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
CD=[list(map(int,input().split())) for j in range(M)]
for i in range(N):
    d=(10**8)*2
    ans=0
    for j in range(M):
        if abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])<d:
            d=abs(AB[i][0]-CD[j][0])+abs(AB[i][1]-CD[j][1])
            ans=j+1
    print(ans)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(N)]
cd = [list(map(int, input().split())) for i in range(M)]

ans = []
for i, (a, b) in enumerate(ab):
  min_dist = 10**20
  idx = -1
  for j, (c, d) in enumerate(cd):
    dij = abs(a - c) + abs(b - d)
    if dij < min_dist:
      min_dist = dij
      idx = j
  ans.append(idx)

print(*ans, sep='\n')

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
C = [list(map(int, input().split())) for _ in range(M)]


for a in A:
    distance = 100
    point = 0
    for i, c in enumerate(C):
        if abs(a[0] - c[0]) + abs(a[1] - c[1]) < distance:
            distance = abs(a[0] - c[0]) + abs(a[1] - c[1])
            point = i
    print(point + 1)