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())
h=[]
p=[]
def man(a,c,b,d):
    s=abs(a-b)+abs(c-d)
    return s
for i in range(n):
    h.append(list(map(int,input().split())))
for j in range(m):
    p.append(list(map(int,input().split())))
for k in range(n):
    l=float("inf")
    for v in range(m):
        x=man(h[k][0],p[v][0],h[k][1],p[v][1])
        if x<l:
            l=x
    print(l)

Submission status: Wrong Answer

Solution code:
def gcd(A, B, C, D):
	l, L = A-C, B-D
	if l<0:
		l = l*(-1)
	if L<0:
		L = L*(-1)
	return l+L
	
N, M = map(int, input().split())
x = []
y = []
n = 0
m = 0
ans = 1
for i in range(N):
	x1, y1 = map(int, input().split())
	x.append(x1)
	y.append(y1)
X = []
Y = []
for l in range(M):
	x2, y2 = map(int, input().split())
	X.append(x2)
	Y.append(y2)
for a in range(N):
	m = gcd(x[a], y[a], X[0], Y[0])
	for b in range(M):
		n = gcd(x[a], y[a], X[b], Y[b])
		if n < m:
			ans = b+1
	print(ans)
	ans = 1

Submission status: Wrong Answer

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

for i in range(n):
  man=1000000000
  ans=0
  for j in range(m):
    if abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])<man:
      man=abs(A[i][0]-B[j][0])+abs(A[i][1]-B[j][1])
      ans=j
  print(ans)

Submission status: Wrong Answer

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

for i in A:
  man=1000000000
  for j in B:
    man=min(man,abs(i[0]-j[0])+abs(i[1]-j[1]))
  print(man)

Submission status: Wrong Answer

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

a_arr = []
b_arr = []
for _ in range(N):
    a, b = map(int, input().split())
    a_arr.append(a)
    b_arr.append(b)
    
c_arr = []
d_arr = []
for _ in range(M):
    c, d = map(int, input().split())
    c_arr.append(c)
    d_arr.append(d)

for n in range(N):
    ans = 0
    min_dis = 2 * 10**8 + 1
    for m in range(M):
        dis = abs(a_arr[n] - c_arr[m]) + abs(b_arr[n] - d_arr[m])
        if dis < min_dis:
            min_dis = dis
            ans = m + 1
    print(ans)

Submission status: Wrong Answer

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

a_arr = []
b_arr = []
for _ in range(N):
    a, b = map(int, input().split())
    a_arr.append(a)
    b_arr.append(b)
    
c_arr = []
d_arr = []
for _ in range(M):
    c, d = map(int, input().split())
    c_arr.append(c)
    d_arr.append(d)

for n in range(N):
    ans = 0
    min_dis = 10**8 + 1
    for m in range(M):
        dis = abs(a_arr[n] - c_arr[m]) + abs(b_arr[n] - d_arr[m])
        if dis < min_dis:
            min_dis = dis
            ans = m + 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)]
for i in range(m):
    c,d = map(int,input().split())
    l = [0]*n
    for i in range(n):
        l[i] = abs(a[i][0]-c)+abs(a[i][1]-d)
    print(l.index(min(l))+1)

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)]

ans = [0 for i in range(n)]
for i in range(n):
    distance = 1e8
    tmp_ans = 1
    for j in range(m):
        tmp_dis = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
        if distance > tmp_dis:
            distance = tmp_dis
            tmp_ans = j + 1
    print(tmp_ans)

Submission status: Wrong Answer

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

a = []
b = []
c = []
d = []
for i in range(n):
    aa, bb = list(map(int, input().split()))
    a.append(aa)
    b.append(bb)
for i in range(m):
    aa, bb = list(map(int, input().split()))
    c.append(aa)
    d.append(bb)

for i in range(n):
    min = 100000001
    p = 1
    for j in range(m):
        z = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if z < min:
            min = z
            p = j + 1

    print(p)

Submission status: Wrong Answer

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

a = []
b = []
c = []
d = []
for i in range(n):
    aa, bb = list(map(int, input().split()))
    a.append(aa)
    b.append(bb)
for i in range(m):
    aa, bb = list(map(int, input().split()))
    c.append(aa)
    d.append(bb)

for i in range(n):
    min = 100000000
    p = 1
    for j in range(m):
        z = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if z < min:
            min = z
            p = j + 1

    print(p)

Submission status: Wrong Answer

Solution code:
while(True):
    try:
        n, m = map(int, input().split())
    except EOFError:
        exit()
    a, b = [[0 for _ in range(n)] for i in range(2)]
    c, d = [[0 for _ in range(m)] for i in range(2)]
    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):
        dist = 1 << 9
        ans = 0
        for j in range(m)[::-1]:
            ans = j + 1 if min(dist, abs(a[i] - c[j]) + abs(b[i] - d[j])) == abs(a[i] - c[j]) + abs(b[i] - d[j]) else ans
            dist = min(dist, abs(a[i] - c[j]) + abs(b[i] - d[j]))
        print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,m=map(int,input().split())
al=[]
bl=[]
ansl=[]
for i in range(n):
  al.append(input())
for i in range(m):
  bl.append(input())
for i in range(n):
  a1,a2=map(int,al[i].split())
  b1,b2=map(int,bl[0].split())
  mi=dis=int(math.sqrt(abs(b1-a1)**2+abs(b2-a2)**2))
  c=1
  for j in range(1,m):
    b1,b2=map(int,bl[j].split())
    dis=int(math.sqrt(abs(b1-a1)**2+abs(b2-a2)**2))
    if mi>dis:
      mi=dis
      c=j+1
  ansl.append(c)
for i in range(len(ansl)):
  print(ansl[i])

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
al=[]
bl=[]
ansl=[]
for i in range(n):
  al.append(input())
for i in range(m):
  bl.append(input())
for i in range(n):
  a1,a2=map(int,al[i].split())
  b1,b2=map(int,bl[0].split())
  mi=dis=abs(b1-a1)**2+abs(b2-a2)**2
  c=1
  for j in range(1,m):
    b1,b2=map(int,bl[j].split())
    dis=abs(b1-a1)**2+abs(b2-a2)**2
    if mi>dis:
      mi=dis
      c=j+1
  ansl.append(c)
for i in range(len(ansl)):
  print(ansl[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)]

ls1 = []
for i in range(N):
    ls2 = []
    for j in range(M):
        ls2.append(abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1]))
    a = min(ls2)
    ls1.append(ls2.index(a))
for i in ls1:
    print(i)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().strip().split(" "))
x=[]
y=[]

for i in range(N):
    c=input().strip().split(" ")
    c=[int(j) for j in c]
    x.append((c[0]))
    y.append((c[1]))
cx=[]
cy=[]

for i in range(M):
    d=input().strip().split(" ")
    d=[int(j) for j in d]
    cx.append((d[0]))
    cy.append((d[1]))

kyori=0

for i in range(N):
    kekka=100000
    basyo=0
    for j in range(M):
        kyori=abs(x[i]-cx[j])+abs(y[i]-cy[j])
        #print(j+1,kyori)
        if(abs(kekka)>abs(kyori) ):
            kekka=kyori
            basyo=j
            
    print(basyo+1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
AB=[]
CD=[]
j=1
for i in range(n):
  AB.append([j]+list(map(int,input().split())))
  j+=1
AB.sort(key=lambda x:x[1])
j=1
for i in range(m):
  CD.append([j]+list(map(int,input().split())))
  j+=1
CD.sort(key=lambda x:x[1])

# print(AB)
# print(CD)

inf=float('inf')
ans=[[0,0] for i in range(n)]
for i in range(len(AB)):
  tmp=inf
  for j in range(-1,2):
    if 0<= i+j <=m-1:
      # print("i",i,"j",j)
      if tmp > abs(AB[i][1]-CD[i+j][1])+abs(AB[i][2]-CD[i+j][2]):
        tmp=abs(AB[i][1]-CD[i+j][1])+abs(AB[i][2]-CD[i+j][2])
        ans[i][0],ans[i][1]=AB[i][0],CD[i+j][0]

ans.sort()

for i in ans:
  print(i[1])

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
B = []
C = []
D = []
for i in range(N):
    x,y = map(int,input().split())
    A.append(x)
    B.append(y)
for i in range(M):
    x,y = map(int,input().split())
    C.append(x)
    D.append(y)
k = 0
for i in range(N):
    g = 51
    for j in range(M):
        t = abs(A[i]-C[j])+abs(B[i]-D[j])
        
        if t < g:
            k = j+1
            g = t
    print(k)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = [tuple(map(int, input().split())) for i in range(n)]
C = [tuple(map(int, input().split())) for j in range(m)]
for i in range(n):
  res = 0
  ans = 1 << 20
  for j in range(m):
    tmp = abs(A[i][0] - C[j][0]) + abs(A[i][1] - C[j][1])
    if tmp < ans:
      ans = tmp
      res = j
  print(res+1)

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
ab = []
cd = []
for _ in range(n):
    ab.append(list(map(int, input().split())))
for _ in range(m):
    cd.append(list(map(int, input().split())))
    
for a,b in ab:
    dis = int(1e8)
    ans = -1
    for i in range(m):      
        c,d = cd[m-i-1][0], cd[m-i-1][1]
        manhattan = abs(a-c) + abs(b-d)
        if dis >= manhattan:
            ans = m-i
            dis = manhattan
    print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split(" ")))
br = []
cr = []
for i in range(a[0]):
    l = list(map(int,input().split(" ")))
    br.append(l)
for j in range(a[1]):
    m = list(map(int,input().split(" ")))
    cr.append(m)
count = 10 ** 8
inde = 0
for b in br:
    for k,c in enumerate(cr):
        d = abs(b[0]-c[0]) + abs(b[1]-c[1])
        if d < count:
            count = d
    for l,c in enumerate(cr):
        if count == abs(b[0]-c[0]) + abs(b[1]-c[1]):
            print(l+1)
            break

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split(" ")))
br = []
cr = []
for i in range(a[0]):
    l = list(map(int,input().split(" ")))
    br.append(l)
for j in range(a[1]):
    m = list(map(int,input().split(" ")))
    cr.append(m)
count = 10 ** 8
inde = 0
for b in br:
    for k,c in enumerate(cr):
        d = abs(b[0]-c[0]) + abs(b[1]-c[1])
        if d < count:
            count = d
            inde = k+1
    print(inde)
    count = 10 ** 8
    inde = 0

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split(" ")))
br = []
cr = []
for i in range(a[0]):
    l = list(map(int,input().split(" ")))
    br.append(l)
for j in range(a[1]):
    m = list(map(int,input().split(" ")))
    cr.append(m)
count = 10 ** 8
inde = 0
for b in br:
    for k,c in enumerate(cr):
        d = abs(b[0]-c[0]) + abs(b[1]-c[1])
        if d < count:
            count = d
            inde = k+1
    print(inde)
    count = 10 ** 8

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(n)]
cd = [list(map(int, input().split())) for x in range(m)]
for i in ab:
    atemp = 100000000
    ans = 0
    for f in range(len(cd)):
        temp = abs(i[0] - cd[f][0]) + abs(i[1] - cd[f][1])
        if atemp > temp:
            atemp = temp
            ans = f + 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for x in range(n)]
cd = [list(map(int, input().split())) for x in range(m)]
for i in ab:
    atemp = 1000
    ans = 0
    for f in range(len(cd)):
        temp = abs(i[0] - cd[f][0]) + abs(i[1] - cd[f][1])
        if atemp > temp:
            atemp = temp
            ans = f + 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
ans=0
ans1=0
tmp=0
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(m):
    x,y=map(int,input().split())
    c.append(x)
    d.append(y)
for i in range(n):
    for j in range(m):
        tmp=abs(a[i]-c[j])+abs(b[i]-d[j])
        if j==0:
            ans=tmp
        if ans>tmp:
            ans1=j+1
            ans=tmp
    print(ans1)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
ans=10000000
ans1=0
tmp=0
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(m):
    x,y=map(int,input().split())
    c.append(x)
    d.append(y)
for i in range(n):
    for j in range(m):
        tmp=abs(a[i]-c[j])+abs(b[i]-d[j])
        if ans>tmp:
            ans1=j+1
            ans=tmp
    print(ans1)
    ans=10000000

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())
    
D = [[0]*m]*n
for i in range(n):
    for j in range(m):
        D[i][j] = abs(a[i]-c[j])+abs(b[i]-d[j])

for i in range(n):
    print(D[i].index(min(D[i]))+1)

Submission status: Wrong Answer

Solution code:
def create_list(n):
    result = [[i for i in map(int,input().split())] for j in range(n)]
    return result 

n,m = map(int,input().split())
x_list   = create_list(n)
y_list   = create_list(m)
ans_list = []

for x in x_list:
    ans   = 0
    min_n = 51
    for i,y in enumerate(y_list):
        temp = abs(x[0]-y[0]) + abs(x[1]-y[1])
        if temp < min_n:
            min_n = temp
            ans = i+1
    ans_list.append(ans)

for num in ans_list:
    print(num)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=[]
p=[]
md=[[None,float('INF')] for i in range(n)]
for i in range(n):
    t1,t2=map(int,input().split())
    s.append([t1,t2])
for i in range(m):
    t1,t2=map(int,input().split())
    p.append([t1,t2])
for i in range(n):
    for j in range(m):
        if md[i][1]>abs(s[i][0]-p[j][0])+abs(s[i][1]-p[j][1]):
            md[i][0]=j+1
for i in range(n):
    print(md[i][0])

Submission status: Wrong Answer

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

ab_list = []
cd_list = []

for i in range(N):
    ab = list(map(int, input().split()))
    ab_list.append(ab)

for i in range(M):
    cd = list(map(int, input().split()))
    cd_list.append(cd)

for a, b in ab_list:
    num = -1
    min_num = 10 ** 8 + 1
    count = 0
    for c, d in cd_list:
        count += 1
        distance = abs(a-c) + abs(b-d)
        if distance < min_num:
            min_num = distance
            num = count
    print(num)

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
A = []
B = []
C = []
D = []
for i in range(N) :
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
for j in range(M) :
    c,d = map(int,input().split())
    C.append(c)
    D.append(d)
for k in range(N) :
    distance = 10**8
    answer = -1
    for l in range(M) :
        p = abs(A[k]-C[l])
        q = abs(B[k]-D[l])
        d = p+q
        if d < distance :
            distance = d
            answer = l+1
    print(answer)

Submission status: Wrong Answer

Solution code:
import math
def distance(x, y, i, j):
    return abs(x - i) + abs(y - j)

N, M = map(int, input().split())
student = []
for i in range(N):
    student.append(list(map(int, input().split())))
checkpoint = []
for i in range(M):
    checkpoint.append(list(map(int, input().split())))

for i in student:
    mini = 100000
    minicp = 0
    for k in range(M):
        j = checkpoint[k]
        if distance(i[0], i[1], j[0], j[1]) < mini:
            mini = distance(i[0], i[1], j[0], j[1])
            minicp = k + 1
    print(minicp)

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)]

if m:
    nums = [None]*n
    for i, ab_i in enumerate(ab):
        min_distance = 100000000
        min_num = 10000
        for j, cd_i in enumerate(cd):
            distance = abs(ab_i[0]-cd_i[0]) + abs(ab_i[1]-cd_i[1])
            if distance < min_distance:
                min_distance = distance
                min_num = j
        nums[i] = min_num+1
    [print(num) for num in nums]

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)]

nums = [None]*n
for i, ab_i in enumerate(ab):
    min_distance = 100000000
    min_num = 10000
    for j, cd_i in enumerate(cd):
        distance = abs(ab_i[0]-cd_i[0]) + abs(ab_i[1]-cd_i[1])
        if distance < min_distance:
            min_distance = distance
            min_num = j
    nums[i] = min_num+1
[print(num) for num in nums]

Submission status: Wrong Answer

Solution code:
poop=input().split()
kpop=int(poop[0])
jpop=int(poop[1])
lop=[]
jop=[]
for i in range(kpop):
    lop.append(input().split())
for i in range(jpop):
    jop.append(input().split())
for i in range(kpop):
    k=999999999999999
    z=0
    for j in range(jpop):
        l=lop[i][0]
        m=jop[j][0]
        n=lop[i][1]
        o=jop[j][1]
        if k>abs(int(l)-int(m))+abs(int(n)-int(o)):
            z=j
            k=abs(int(l)-int(m))+abs(int(n)-int(o))
    print(z)

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,j in a:
    dis=10**8
    point=0
    for k in range(len(b)):
        if abs(i-b[k][0])+abs(j-b[k][1])<dis:
            dis=abs(i-b[k][0])+abs(j-b[k][1])
            point=k
    print(point+1)

Submission status: Wrong Answer

Solution code:
N,M = (int(i) for i in input().split())
a=[]
b=[]
c=[]
d=[]

for i in range(N):
    A,B = (int(i) for i in input().split())
    a.append(A)
    b.append(B)

for i in range(M):
    C,D = (int(i) for i in input().split())
    c.append(C)
    d.append(D)


closest = N*[0]

for i in range(N):
    minimum = abs(a[i]-c[0])+abs(b[i]-d[0])
    number = 1
    for j in range(1,M):
        distance = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance < minimum:
            number = j+1
    closest[i] = number

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

Submission status: Wrong Answer

Solution code:
N,M = (int(i) for i in input().split())

student = []
for i in range(N):
    a,b = (int(k) for k in input().split())
    student.append([a,b])

points = []
for i in range(M):
    c,d = (int(k) for k in input().split())
    points.append([a,b])
    
distance = []
kyori = []

'''
for i in range(N):
    for j in range(1):
        kyori.append(abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1]))
    distance.append(min(kyori))

for i in range(N):
    for j in range(1,M):
        kyori[j] = abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1])
    distance.append(min(kyori))
'''

for i in range(1):
    for j in range(M):
        kyori.append(abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1]))
        print(kyori)
    distance.append(min(kyori))

for i in range(1,N):
    for j in range(M):
        kyori[j] = abs(student[i][0]-points[j][0]) + abs(student[i][1]-points[j][1])
        print(kyori)
    distance.append(min(kyori))

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

Submission status: Wrong Answer

Solution code:
N,M = (int(i) for i in input().split())


student = []
for i in range(N):
    a,b = (int(i) for i in input().split())
    student.append([a,b])

point = []
for j in range(M):
    c,d = (int(i) for i in input().split())
    point.append([c,d])

minimum = N*[""]
number = N*[0]



for i in range(N):
    minimum[i] = abs(student[i][0]-point[0][0]) + abs(student[i][1]-point[0][1])
    for j in range(M):
        distance = abs(student[i][0]-point[j][0]) + abs(student[i][1]-point[j][1])
        if distance<= minimum[i]:
            number[i] = j+1
        minimum[i] = min(distance,minimum[i])

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

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 g in ab:
    dis = 2*(10**8)
    point = 0
    for c in range(m):
        d = abs(g[0]-cd[c][0]) + abs(g[1]-cd[c][1])
        if(dis > d):
            dis = d
            point = c + 1
    print(point)

Submission status: Wrong Answer

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

ans = 50
distance = 0

for i in range(n):
    for j in range(m):
        e = abs(a[i]-c[j])+abs(b[i]-d[j])
        if distance == 0:
            distance = e
            ans = j
        elif distance > e:
            distance = e
            ans = j
    print(ans+1)
    ans = 50
    distance = 0

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
for i in range(N):
    min_distance = 99999
    check_point = 0
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j
    print(check_point+1)

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
ab = [[int(a) for a in input().split()] for _ in range(N)]
cd = [[int(a) for a in input().split()] for _ in range(M)]
check_point = 0
for i in range(N):
    min_distance = 99999
    for j in range(M):
        manhattan_distance = abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
        if min_distance > manhattan_distance:
            min_distance = manhattan_distance
            check_point = j
    print(check_point+1)

Submission status: Wrong Answer

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

students = [tuple(map(int, input().split())) for i in range(n)]
checkpoints = [tuple(map(int, input().split())) for j in range(m)]

def distance(u, v):
    return abs(u[0] - v[0]) + abs(u[1] - v[1])


for s in students:
    j = -1
    v = 2*10**8+1
    for i, cp in enumerate(checkpoints):
        d = distance(s, cp)
        if d < v:
            j = i
            v = d
    print(j+1)

Submission status: Wrong Answer

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

for i in range(m):
  check.append(list(map(int, input().split())))

for i in pos:
  closest = [10**8, 0]
  for j, v in enumerate(check):
    if abs(i[0] - v[0]) + abs(i[1] - v[1]) < closest[0]:
      closest[0], closest[1] = abs(i[0] - v[0]) + abs(i[1] - v[1]), j + 1
  print(closest[1])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
students =[]
points = []
maximum = 10**8
check = 0
for i in range(n):
  students.append(list(map(int, input().split())))

for i in range(m):
  points.append(list(map(int, input().split())))

for i in students:
  temp = maximum
  for index, j in enumerate(points):
    if abs(i[0] - j[0]) + abs(i[1] - j[1]) < temp:
      temp = abs(i[0] - j[0]) + abs(i[1] - j[1])
      check = index + 1
  print(check)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# author:   noname
# url:      https://github.com/pettan0818
# license:  mit license
# created: 木 10/12 18:57:45 2017

# usage
#
"""
import math


def calc_distance(student_post, checkpoint_post):
    return int(math.fabs(student_post[0] - checkpoint_post[0]) + math.fabs(student_post[1] - checkpoint_post[1]))


if __name__ == '__main__':
    import doctest
    doctest.testmod()

    first = input()
    first = first.split(" ")
    data = [int(line) for line in first]

    student_num = data[0]
    checkpoint_num = data[1]

    student_pos_data = [[int(i) for i in input().split(" ")] for i in range(student_num)]
    checkpoint_data = [[int(i) for i in input().split(" ")] for i in range(checkpoint_num)]
    print(student_pos_data)
    print(checkpoint_data)

    for each_student in student_pos_data:
        dis_list = [calc_distance(each_student, i) for i in checkpoint_data]
        print(dis_list)
        print(dis_list.index(min(dis_list)) + 1)

Submission status: Wrong Answer

Solution code:
import math;

n, m = map(int, input().split(" "));
ab = [];
for i in range(0, n):
    ab.append(input().split(" "));

cd = [];
for i in range(0, m):
    cd.append(input().split(" "));

for i in range(0, n):
    dist=9999999999999
    nearm=0;
    for j in range(0, m):
         dist2 = math.fabs(int(ab[i][0]) - int(cd[j][0])) + math.fabs(int(ab[i][1]) - int(cd[j][1]));
         if dist2 < dist:
            dist = dist2;
            nearm=j;
    print(nearm);

Submission status: Wrong Answer

Solution code:
def solve():
  ar = raw_input().split(' ')
  N = int(ar[0])
  M = int(ar[1])
  sts = []
  for n in range(N) :
    ar = raw_input().split(' ')
    a = int(ar[0])
    b = int(ar[1])
    sts.append((a, b))
  cks = []
  for m in range(M) :
    ar = raw_input().split(' ')
    c = int(ar[0])
    d = int(ar[1])
    cks.append((c, d))

  for st in sts :
    #print st
    mind = 999999
    mini = -1
    for i in range(M):
      ckx = cks[i][0]
      cky = cks[i][1]
      d = abs(st[0] - ckx) + abs(st[1] - cky)
      #print 'd=',d
      if d < mind :
        mind = d
        mini = i
    #print 'mind=',mind, ',mini=',mini 
    print mini + 1

if __name__ == '__main__':
  solve()

Submission status: Wrong Answer

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

student = [  tuple( map(int, input().split()) ) for x in range(N)]
point = [ tuple( map(int, input().split()) ) for x in range(M)]


for (x1, y1) in point :
    data =  [ abs(x1 - x2) + abs(y1 - y2) for (x2, y2) in student ]
    ans = data.index(min(data))
    print(ans + 1)

Submission status: Wrong Answer

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

student = [];
pos = [];
for i in range(N) :
	a, b = map(int, input().split(" "))
	student.append((a, b))

for i in range(M) :
	a, b = map(int, input().split(" "))
	pos.append((a,b))

for st in student :
	ans = -1;
	score = 100000000;
	for i in range(M) :
		tmpscore = abs(st[0] - pos[i][0]) + abs(st[1] - pos[i][1])
		if score > tmpscore :
			score = tmpscore;
			ans = i;
	print(ans+1);

Submission status: Wrong Answer

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

a = []
b = []

for i in range(n):
    tmp1, tmp2 = list(map(int, input().split()))
    a.append(tmp1)
    b.append(tmp2)

c = []
d = []

for i in range(m):
    tmp1, tmp2 = list(map(int, input().split()))
    c.append(tmp1)
    d.append(tmp2)

for i in range(n):
    tmp = abs(a[0] - c[0]) + abs(b[0] - d[0])
    s = 1
    for j in range(m):
        tmp3 = abs(a[i] - c[j]) + abs(b[i] - d[j])
        if tmp3 < tmp:
            tmp = tmp3
            s = j + 1
    print(s)

Submission status: Wrong Answer

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

for i in range(m):
    check.append(list(map(int, input().split())))


ans = []

for i in range(n):
    dist = []
    for j in range(m):
        tmp = abs(stu[i][0] - check[j][0]) + abs(stu[i][1] - check[j][1])
        dist.append(tmp)
    mi = dist.index(min(dist))
    ans.append(mi)


for i in range(len(ans)):
    print(ans[i])

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
s = []
d = []
for i in range(n):
    x, y = map(int, input().split())
    s.append([x, y])
for i in range(m):
    x, y = map(int, input().split())
    d.append([x, y])
for i in s:
    a = m
    c = abs(i[0] - d[0][0]) + abs(i[1] - d[0][1])
    for j in range(1, m):
        c_t = abs(i[0] - d[j][0]) + abs(i[1] - d[j][1])
        if c_t < c:
            c = min(c, c_t)
            a = j
    print(a)