s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s781728335 | p03774 | u609814378 | 1577235762 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1 | a |
s417538480 | p03774 | u716530146 | 1576903750 | Python | PyPy3 (2.4.0) | py | Runtime Error | 181 | 39408 | 537 | #!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1
n,m=map(int,input().split())
ab=[tuple(map(int,input().split())) for i in range(n)]
cd=[tuple(map(int,input().split())) for i in range(m)]
for a,b in ab:
tmp=inf
candi=0
for j in range(n):
c=cd[j][0]
d=cd[j][1]
k=abs(a-c)+abs(b-d)
if tmp>k:
tmp=k
candi=j
print(candi+1)
|
s650006126 | p03774 | u905582793 | 1576565370 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 219 | n,m=map(int,input().split())
std = [list(map(int,input().split())) for i in range(n)]
chk = [list(map(int,input().split())) for i in range(m)]
for s in std:
print(min(lambda i:abs(s[0]-chk[i][0])+abs(s[1]-chk[i][1]))) |
s603261825 | p03774 | u799691369 | 1575228378 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 439 | N, M = map(int, input().split())
students = []
for i in range(N):
students.append(input().split())
checkpoints = []
for i in range(M):
checkpoints.append(input().split())
for x1, y1 in students:
result = 10**8
index = 1
for x2, y2 in checkpoints:
val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
if result > val:
ans = index
result = val
index += 1
print(ans) |
s713105477 | p03774 | u574226814 | 1575072253 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 664 | import math
def getDist(a,b,c,d):
return abs(a-c) + abs(b-d)
def findSmallest(student, checkPoints):
[a,b] = student
shortest = math.inf
index = 1
for checkPoint in checkPoints:
[c,d] = checkPoint
dist = getDist(a,b,c,d)
if dist < shortest:
shortest = dist
indexAns = index
index += 1
return indexAns
n,m=[int(x) for x in input().split()]
students = []
for x in range(n):
students.append([int(x) for x in input().split()])
checkPoints = []
for x in range(m):
checkPoints.append([int(x) for x in input().split()])
for student in students:
print(findSmallest(student, checkPoints[:]))
"""
1 2
2 0
-1 0
1 0
""" |
s893843591 | p03774 | u355371431 | 1574378518 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 39280 | 462 | N,M = map(int,input().split())
ab = []
for i in range(N):
a,b = map(int,input().split())
ab.append((a,b))
cd = []
for i in range(N):
a,b = map(int,input().split())
cd.append((a,b))
ans = []
for i in range(len(ab)):
aaa = 1000000000
for j in range(len(cd)):
man = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
if(man < aaa):
aaa = man
cnt = j + 1
ans.append(cnt)
for i in ans:
print(i) |
s038725596 | p03774 | u355371431 | 1574378218 | Python | PyPy3 (2.4.0) | py | Runtime Error | 182 | 39152 | 450 | N,M = map(int,input().split())
ab = []
for i in range(N):
a,b = map(int,input().split())
ab.append((a,b))
cd = []
for i in range(N):
a,b = map(int,input().split())
cd.append((a,b))
ans = []
for i in range(N):
aaa = 1000000000
for j in range(M):
man = abs(ab[i][0] - cd[j][0]) - abs(ab[i][1] - cd[j][1])
if(man < aaa):
aaa = man
cnt = j + 1
ans.append(cnt)
for i in ans:
print(i) |
s172475117 | p03774 | u983138042 | 1574028894 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 483 | N, M = map(int, input().strip().split())
a_b = []
for i in range(N):
array = list(map(int, input().strip().split()))
a_b.append(array)
c_d = []
for i in range(M):
array = list(map(int, input().strip().split()))
c_d.append(array)
for n in range(N):
mind = 200000001
for m in range(M):
dist = abs(a_b[n][0] - c_d[m][0]) + abs(a_b[n][1] - c_d[m][1])
if dist < mind:
mind = dist
checkpoint = m + 1
print(checkpoint)
|
s288342304 | p03774 | u983138042 | 1574028806 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 486 | N, M = map(int, input().strip().split())
a_b = []
for i in range(N):
array = list(map(int, input().strip().split()))
a_b.append(array)
c_d = []
for i in range(M):
array = list(map(int, input().strip().split()))
c_d.append(array)
for n in range(N):
mind = 2 * 10^8 + 1
for m in range(M):
dist = abs(a_b[n][0] - c_d[m][0]) + abs(a_b[n][1] - c_d[m][1])
if dist < mind:
mind = dist
checkpoint = m + 1
print(checkpoint)
|
s925083792 | p03774 | u089230684 | 1573699006 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 902 | #include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
struct node
{
ll x,y;
} a[N],b[N];
ll d(node c,node d)
{
return abs(c.x-d.x)+abs(c.y-d.y);
}
int main()
{
std::ios::sync_with_stdio(false);
int n,m;
while(cin>>n>>m)
{
for(int i=1; i<=n; i++)
{
cin>>a[i].x>>a[i].y;
}
for(int i=1; i<=m; i++)
{
cin>>b[i].x>>b[i].y;
}
for(int i=1; i<=n; i++)
{
ll dis=1e18,p=0;
for(int j=1; j<=m; j++)
{
if(d(a[i],b[j])<dis)
{
dis=d(a[i],b[j]);
p=j;
}
}
cout<<p<<endl;
}
}
return 0;
}
|
s779898148 | p03774 | u276115223 | 1573500684 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 606 | # ABC 057: B – Checkpoints
n, m = [int(s) for s in input().split()]
a = []
b = []
for i in range(n):
tmp = [int(s) for s in input().split()]
a.append(tmp[0])
b.append(tmp[1])
c = []
d = []
for j in range(m):
tmp = [int(s) for s in input().split()]
c.append(tmp[0])
d.append(tmp[1])
for i in range(n):
checkpoint = 0
distance = abs(c[i] - a[0]) + abs(d[i] - b[0])
for j in range(m):
if distance > abs(c[j] - a[i]) + abs(d[j] - b[i]):
distance = abs(c[j] - a[i]) + abs(d[j] - b[i])
checkpoint = j
print(checkpoint + 1)
|
s062292874 | p03774 | u212253038 | 1573500257 | Python | PyPy3 (2.4.0) | py | Runtime Error | 160 | 38296 | 417 | N, M = map(int, input().split())
st = []
ch = []
for i in range(N):
st.append([*map(int, input().split())])
for i in range(M):
ch.append([*map(int, input().split())])
for i in range(N):
x = float('inf')
c = 0
for j in range(M):
if abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1]) < x:
x = abs(st[i][0]-ch[j][0])+abs(st[i][1]-ch[j][1])
c = j+1
print(c) |
s198305606 | p03774 | u209619667 | 1573135441 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 336 | a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(a)]
for s in S:
count = 0
ab = 10**8
p = 10**8
for cp in CP:
total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
count +=1
if ab > total:
ab = total
p = count
print(p) |
s354445549 | p03774 | u209619667 | 1573135231 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 331 | a,b = map(int,input().split())
S = [list(map(int,input().split())) for i in range(a)]
CP = [list(map(int,input().split())) for i in range(a)]
for s in S:
count = 0
ab = 10**8
p = 10**8
for cp in CP:
total = abs(s[0]-cp[0]) + abs(s[1]-cp[1])
count +=1
if ab > total:
ab = total
p = count
print(p) |
s606868179 | p03774 | u281610856 | 1572063080 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 388 |
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 i in range(n):
v_min = float('inf')
for j in range(m):
v = abs(A[i] - C[j]) + abs(B[i] - D[j])
if v_min > v:
v_min = v
ans = j + 1
print(ans) |
s674656132 | p03774 | u816645498 | 1571595363 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 550 | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < (int)n; ++i)
int main()
{
int N, M;
scanf("%d %d", &N, &M);
int a[N], b[N];
REP(i, N) scanf("%d %d", &a[i], &b[i]);
int c[M], d[M];
REP(i, M) scanf("%d %d", &c[i], &d[i]);
REP(i, N) {
int res = -1;
int dis = 1e9;
REP(j, M) {
int tmp = abs(c[j] - a[i]) + abs(d[j] - b[i]);
if(tmp < dis) dis = tmp, res = j + 1;
}
printf("%d\n", res);
}
return 0;
} |
s263522831 | p03774 | u747602774 | 1570035632 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 349 | N,M=map(int,input().split())
student=[list(map(int,input().split())) for n in range(N)]
check=[list(map(int,input().split())) for m in range(M)]
for n in range(N):
man=200000001
for m in range(M):
dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
point=m+1
if dis<man:
man=dis
ans=point
print(ans)
|
s652602385 | p03774 | u747602774 | 1570035603 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 349 | N,M=map(int,input().split())
student=[list(map(int,input().split())) for n in range(N)]
check=[list(map(int,input().split())) for m in range(M)]
for n in range(N):
man=100000001
for m in range(M):
dis=abs(student[n][0]-check[m][0])+abs(student[n][1]-check[m][1])
point=m+1
if dis<man:
man=dis
ans=point
print(ans)
|
s556484949 | p03774 | u354916249 | 1568777774 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 543 | N, M = map(int, input().split())
AB = []
for _ in range(N):
AB.append(list(map(int, input().split())))
CD = []
for _ in range(M):
CD.append(list(map(int, input().split())))
for i in range(N):
distance = 10**8+7
for j in range(M)[::-1]:
temp = abs(AB[i][0] - CD[j][0]) + abs(AB[i][1] - CD[j][1])
# print(AB[i][0] - CD[j][0],AB[i][1] - CD[j][1])
# print('temp=',temp,'j=',j)
if temp <= distance:
distance = temp
ans = j+1
# print('ans=',ans)
print(ans) |
s855804993 | p03774 | u332906195 | 1568608718 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 343 | 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(N)]
for a, b in AB:
ans, maxD = 0, 10 ** 10
for i, (c, d) in enumerate(CD):
if abs(a - c) + abs(b - d) < maxD:
ans, maxD = i + 1, abs(a - c) + abs(b - d)
print(ans)
|
s604885136 | p03774 | u640603056 | 1567894130 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 623 |
#インポート
import sys
#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()
N, M = ISI()
ab = [list(ISI()) for _ in range(N)]
cd = [list(ISI()) for _ in range(M)]
for i in range(N):
min = 100
for j in range(M):
n = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
if min > n:
min = n
point = j+1
print(point) |
s580160271 | p03774 | u640603056 | 1567894054 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 622 | #インポート
import sys
#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()
N, M = ISI()
ab = [list(ISI()) for _ in range(N)]
cd = [list(ISI()) for _ in range(M)]
for i in range(N):
min = 100
for j in range(M):
n = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
if min > n:
min = n
point = j+1
print(point) |
s467225254 | p03774 | u623349537 | 1567636277 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 542 | N, M = map(int, input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(N)]
d = [0 for i in range(N)]
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):
closest_ind = -1
closest_dist = 10000000000
for j in range(M):
if closest_dist > abs(a[i] - c[j]) + abs(b[i] - d[j]):
closest_ind = j
closest_dist = abs(a[i] - c[j]) + abs(b[i] - d[j])
print(closest_ind + 1) |
s514986708 | p03774 | u248670337 | 1566422563 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 37 | 3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5 |
s400408546 | p03774 | u263226212 | 1566348059 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3060 | 425 | # -*- coding: utf-8 -*-
# input
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)]
# solve & output
for i in range(N):
min_diff = 10 ** 8
for j in range(M):
diff = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
if min_diff > diff:
min_diff = diff
ans = j + 1
print(ans)
|
s236749468 | p03774 | u900303768 | 1564837078 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 422 | n, m = map(int,input().split())
la = []
for i in range(n):
a, b = map(int, input().split())
la.append((a,b))
ca = []
for i in la:
a, b = map(int, input().split())
ca.append((a,b))
for i in range(len(la)):
mi = 1000000001
ans = 0
for j in range(len(ca)):
p = abs(la[i][0]-ca[j][0]) + abs(la[i][1]-ca[j][1])
if p < mi:
mi = p
ans = j+1
print(ans)
|
s436052783 | p03774 | u900303768 | 1564807186 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 425 | n, m = map(int,input().split())
la = []
for i in range(n):
a, b = map(int, input().split())
la.append((a,b))
ca = []
for i in la:
a, b = map(int, input().split())
ca.append((a,b))
for i in ca:
mi = 1000000001
ans = 0
for j in range(len(ca)):
if abs(i[0]-ca[j][0]) + abs(i[1]-ca[j][1]) < mi:
mi = abs(i[0]-ca[j][0]) + abs(i[1]-ca[j][1])
ans = j+1
print(ans)
|
s401078762 | p03774 | u900303768 | 1564806595 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 39408 | 416 | n, m = map(int,input().split())
la = []
for i in range(n):
a, b = map(int, input().split())
la.append((a,b))
ca = []
for i in range(n):
a, b = map(int, input().split())
ca.append((a,b))
for i in la:
mi = 1000000001
ans = 0
for k,j in enumerate(ca):
if abs(i[0]-j[0]) + abs(i[1]-j[1]) < mi:
mi = abs(i[0]-j[0]) + abs(i[1]-j[1])
ans = k+1
print(ans)
|
s622325367 | p03774 | u900303768 | 1564806180 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 416 | n, m = map(int,input().split())
la = []
for i in range(n):
a, b = map(int, input().split())
la.append([a,b])
ca = []
for i in range(n):
a, b = map(int, input().split())
ca.append([a,b])
for i in la:
mi = 1000000001
ans = 0
for k,j in enumerate(ca):
if abs(i[0]-j[0]) + abs(i[1]-j[1]) < mi:
mi = abs(i[0]-j[0]) + abs(i[1]-j[1])
ans = k+1
print(ans)
|
s830976388 | p03774 | u142693157 | 1563688354 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 758 | n, m = map(int, input().split())
a = []
b = []
c = []
d = []
for i in range(n):
temp = list(map(int, input().split()))
a.append(temp[0])
b.append(temp[1])
for i in range(m):
temp = list(map(int, input().split()))
c.append(temp[0])
d.append(temp[1])
ans = []
for i in range(n):
min_dis = 1000
for j in range(m):
distance = abs(c[j] - a[i]) + abs(d[j] - b[i])
#print("学生{}, {} チェックポイント{}, {}".format(a[i], b[i], c[j], d[j]))
#print("距離番号{} = {}".format(j, distance))
if min_dis > distance:
min_dis = distance
min_num = j
#print("更新")
ans.append(min_num)
for i in range(n):
print(ans[i] + 1)
|
s640278169 | p03774 | u423585790 | 1563569051 | Python | PyPy3 (2.4.0) | py | Runtime Error | 195 | 38512 | 1446 | #!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')
#A
def A():
a, b = LI()
print((a+b)%24)
return
#B
def B():
n, m = LI()
ab = LIR(n)
cd = LIR(m)
for a, b in ab:
ans = inf
an = 0
for num, cdi in cd:
c, d = cdi
if ans > abs(a - c) + abs(b - d):
an = num
print(an)
return
#C
def C():
return
#D
def D():
return
#Solve
if __name__ == '__main__':
B()
|
s592037099 | p03774 | u373499377 | 1563455110 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 681 | def main():
n, m = map(int, input().split())
students = [tuple(map(int, input().split())) for i in range(n)]
check_points = [tuple(map(int, input().split())) for i in range(m)]
for a, b in students:
dist = [abs(a - c) + abs(b - d) for c, d in check_points]
print(check_points.index(min(dist) + 1))
# for st in students:
# min_pt = check_points[0]
# for pt in check_points:
# if abs(pt[0] - st[0]) + abs(pt[1] - st[1]) < \
# abs(min_pt[0] - st[0]) + abs(min_pt[1] - st[1]):
# min_pt = pt
# print(check_points.index(min_pt) + 1)
if __name__ == "__main__":
main()
|
s029049684 | p03774 | u405256066 | 1562098339 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 512 | from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
students = []
for _ in range(N):
students.append([int(x) for x in stdin.readline().rstrip().split()])
checkpoints = []
for _ in range(M):
checkpoints.append([int(x) for x in stdin.readline().rstrip().split()])
for i in students:
tmp = 10000
for ind,j in enumerate(checkpoints):
dist = abs(i[0] - j[0]) + abs(i[1] - j[1])
if dist < tmp:
tmp = dist
ans = ind+1
print(ans) |
s880178930 | p03774 | u714300041 | 1561839302 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 349 | import numpy as np
N, M = map(int, input().split())
A = [map(int, input().split()) for _ in range(N)]
B = [map(int, input().split()) for _ in range(M)]
for (x, y) in A:
d = np.array([])
for q in B:
print("q = ", q)
print("*q=", *q,)
a, b = q
d = np.append(d, abs(x-a) + abs(y-b))
print(np.argmin(d) + 1) |
s578993694 | p03774 | u539517139 | 1560899561 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 233 | 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:
k=[]
for c,d in c:
k.append(abs(a-c)+abs(b-d))
print(k.index(min(k))+1) |
s899647278 | p03774 | u073549161 | 1560567502 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38384 | 475 | import math
n,m = map(int, input().split())
dat_n = []
dat_m = []
for i in range(n):
a,b = map(int, input().split())
dat_n.append((a, b))
for i in range(m):
a,b = map(int, input().split())
dat_m.append((a, b))
for i in range(n):
a, b = dat_n[i]
index = -1
distance = math.inf
for j in range(m):
c,d = dat_m[j]
t = abs(a-c) + abs(b-d)
if t < distance:
index = j + 1
distance = t
print(index)
|
s686446058 | p03774 | u095756391 | 1560027286 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 367 | 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 i in range(n):
a, b = map(int, input().split())
ans = abs(a-cd[0][0]) + abs(b-cd[0][1])
for j in range(m):
dif = abs(a - cd[j][0]) + abs(b - cd[j][1])
ans = min(dif, ans)
print(ans)
|
s887927280 | p03774 | u623687794 | 1559772919 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 409 | n,m=map(int,input().split())
students=[]
checks=[]
def mdistance([a,b],[c,d]):
return abs(a-c)+abs(b-d)
for i in range(n):
a=list(map(int,input().split()))
students.append(a)
for i in range(m):
checks.append(list(map(int,input().split())))
for i in range(n):
anspoint=0
for j in range(m):
if mdistance(students[i],checks[j])<mdistance(students[i],checks[anspoint]):
anspoint=j
print(j) |
s324253572 | p03774 | u416758623 | 1559563360 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 427 | 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 i in range(n):
minNum = 10000
for j in range(m):
if abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1]) < minNum:
minNum = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
ans = j + 1
print(ans) |
s663044339 | p03774 | u844005364 | 1559256386 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 365 | n, m = map(int, input().split())
abs = [list(map(int, input().split())) for _ in range(n)]
cds = [list(map(int, input().split())) for _ in range(m)]
for a, b in abs:
min_distance = float("inf")
min_checkpoint = 0
for i, cd in enumerate(cds):
c, d = cd
if abs(c - a) + abs(d - b) < min_checkpoint:
min_checkpoint = i + 1
print(min_checkpoint) |
s699662008 | p03774 | u322185540 | 1558658169 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 501 | n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
x[i],y[i] = map(int,input().split())
for j in range(m):
mx[j],my[j] = map(int,input().split())
#print(x)
#print(y)
#print(mx)
#print(my)
ans = [0]*n
#print(ans)
for k in range(n):
dis = 1000000000
cnt = 1
for l in range(n):
if abs(x[k]-mx[l])+abs(y[k]-my[l]) < dis:
dis = abs(x[k]-mx[l])+abs(y[k]-my[l])
cnt = l+1
ans[k] = cnt
for h in ans:
print(h) |
s569103201 | p03774 | u322185540 | 1558650405 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 447 | n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
x[i],y[i] = map(int,input().split())
for j in range(m):
mx[j],my[j] = map(int,input().split())
ans = [0]*n
for k in range(n):
dis = 1000000000
cnt = 1
for l in range(n):
if abs(x[k]-mx[l])+abs(y[k]-my[l]) < dis:
dis = abs(x[k]-mx[l])+abs(y[k]-my[l])
cnt = l+1
ans[k] = cnt
for h in ans:
print(h) |
s296266805 | p03774 | u322185540 | 1558650176 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 438 | n,m = map(int,input().split())
x = [0]*n
y = [0]*n
mx = [0]*m
my = [0]*m
for i in range(n):
x[i],y[i] = map(int,input().split())
for j in range(m):
mx[j],my[j] = map(int,input().split())
ans = [0]*n
for k in range(n):
dis = 0
cnt = 1
for l in range(n):
if abs(x[k]-xs[l])+abs(y[k]-ys[l]) > dis:
dis = abs(x[k]-xs[l])+abs(y[k]-ys[l])
cnt = l+1
ans[k] = cnt
for h in ans:
print(h) |
s191084723 | p03774 | u315703650 | 1558380508 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 423 | n,m = map(int,input().split())
a=[]
b=[]
c=[]
d=[]
for i in range(n):
a1,b1=map(int,input().split())
a.append(a1)
b.append(b1)
for i in range(m):
c1,d1=map(int,input().split())
c.append(c1)
d.append(d1)
for i in range(n):
min_len = 100000000
for j in range(m):
len = abs(c[j]-a[i])+abs(d[j]-b[i])
if len < min_len:
min_len=len
cnt = j+1
print(cnt) |
s536440897 | p03774 | u220345792 | 1558051818 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 371 | N, M = map(int, input().split())
stu = []
che = []
for i in range(N):
stu.append(list(map(int, input().split())))
for i in range(M):
che.append(list(map(int, input().split())))
for i in stu:
x, y = i[0], i[1]
ans = 0
tmp = 99999999999999
for j in che:
if abs(x-j[0])+abs(y-j[1]) < tmp:
tmp = abs(x-j[0])+abs(y-j[1])
ans = j + 1
print(ans) |
s170905873 | p03774 | u856169020 | 1557766397 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 382 | N, M = map(int, input().split())
stu = []
for _ in range(N):
stu.append(tuple(map(int, input().split())))
che = []
for _ in range(M):
che.append(tuple(map(int, input().split())))
for i in range(N):
ans = 0
min_l = pow(10, 10)
for j in range(M):
l = abs(stu[i][0] - che[i][0]) + abs(stu[i][1] - che[i][1])
if l < min_l:
min_l = l
ans = j+1
print(ans) |
s816838335 | p03774 | u806855121 | 1556976953 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 345 | 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(N)]
for s in S:
minC = 10**10
idx = 0
for i, c in enumerate(C):
d = abs(s[0]-c[0]) + abs(s[1]-c[1])
if d < minC:
minC = d
idx = i + 1
print(idx)
|
s839889610 | p03774 | u785578220 | 1556851933 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3264 | 484 | a,b = map(int, input().split())
x = []
z = []
m =19999999999999
s = 1
for i in range(a):
ta , tb = map(int, input().split())
x.append([ta,tb])
for i in range(a):
ta , tb = map(int, input().split())
z.append([ta,tb])
for ta , tb in x:
s = 0
m =19999999999999
for n,(s,y) in enumerate(z):
print(n,s,y)
# print(m , abs(s-ta)+abs(y-tb))
if m >= abs(s-ta)+abs(y-tb):
m = abs(s-ta)+abs(y-tb)
s = n
print(s+1) |
s796462382 | p03774 | u694810977 | 1556845511 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 615 | N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
for i in range(N):
a,b = map(int,input().split())
a_list.append(a)
b_list.append(b)
for i in range(M):
c,d = map(int,input().split())
c_list.append(c)
d_list.append(d)
for i in range(N):
min = abs(a_list[0] - c_list[0]) + abs(b_list[0] - d_list[0])
for j in range(M):
distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
if min > distance:
min = distance
index = j
lists.append(index+1)
for i in range(len(lists)):
print(lists[i])
|
s501108504 | p03774 | u694810977 | 1556844986 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 572 | N,M = map(int,input().split())
a_list = []
b_list = []
c_list = []
d_list = []
lists = []
max = 0
for i in range(N):
a,b = map(int,input().split())
a_list.append(a)
b_list.append(b)
for i in range(M):
c,d = map(int,input().split())
c_list.append(c)
d_list.append(d)
for i in range(N):
min = 9999
for j in range(M):
distance = abs(a_list[i] - c_list[j]) + abs(b_list[i] - d_list[j])
if min > distance:
min = distance
index = j
lists.append(index+1)
for i in range(len(lists)):
print(lists[i])
|
s581945362 | p03774 | u893132811 | 1556210455 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 455 | 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 j in range(M):
x, y = map(int, input().split())
c.append(x)
d.append(y)
for i in range(N):
minDist = 10**8 * 2
for j in range(M):
dist = abs(c[j]-a[i]) + abs(d[j]-b[i])
if dist < minDist:
minDist = dist
ans = j
print(ans+1)
|
s087257527 | p03774 | u163320134 | 1555397086 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 344 | n,m=map(int,input().split())
pos1=[list(map(int,input().split())) for _ in range(n)]
pos2=[list(map(int,input().split())) for _ in range(m)]
ans=[0]*n
for i in range(n):
lim=10**9
for j in range(m):
tmp=abs(pos1[i][0]-pos2[i][0])+abs(pos1[i][1]-pos2[i][1])
if tmp<lim:
tmp=lim
ans[i]=j
for i in range(n):
print(ans[i]) |
s121575907 | p03774 | u655048024 | 1555195753 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 506 | N,M = map(int,input().split())
students = []
points = []
for i in range(N):
students.append(list(map(int,input().split())))
for j in range(M):
points.append(list(map(int,input().split())))
for k in range(N):
Q = 999999999999999
for l in range(M):
x_ = students[k,0]-points[l,0]
y_ = students[k,1]-points[l,0]
if (x_<0):
x_ = x_ *(-1)
if (y_<0):
y_ = y_ *(-1)
L = x_ + y_
z = 0
if(L<Q):
Q = L
z = l+1
else:
None
print(z)
|
s413933182 | p03774 | u285443936 | 1553828317 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 690 | N, M = map(int, input().split())
a, b, c, d = [],[],[],[]
for i in range(N):
ai, bi = map(int, input().split())
a.append(ai)
b.append(bi)
# print(a, b)
for j in range(M):
cj, dj = map(int, input().split())
c.append(cj)
d.append(dj)
#print(a,b,c,d)
for i in range(N):
dist, min_dist = 0, INF
ans = 1
for j in range(M):
dist = abs(c[j] - a[i]) + abs(d[j] - b[i])
if dist < min_dist:
ans = j+1
min_dist = dist
# print("ai:{}, bi:{}, cj:{}, dj:{}, dist:{}, ans:{}".format(a[i], b[i], c[j], d[j], dist, ans))
# print("i:{}, j:{}, dist:{}, min_dist:{}, ans:{}".format(i, j, dist, min_dist, ans))
# min_dist = min(dist, min_dist)
print(ans) |
s659268924 | p03774 | u878138257 | 1553828060 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 304 | n,m = map(int,input().split())
listA = [list(map(int, list(input()))) for i in range(n)]
listB = [list(map(int, list(input()))) for j in range(m)]
listC=[]
for k in range(n):
for l in range(m):
listC.append(abs(listA[k][0]-listB[l][0])+abs(list[k][1]-listB[l][1]))
listC.sort()
print(listC[0])
|
s013198376 | p03774 | u227082700 | 1553552230 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 427 | n,m=map(int,input().split())
o,p,q,r=[],[],[],[]
def kyori(a,b,c,d):return abs(a-b)+abs(c-d)
for i in range(n):
a,b=map(int,input().split())
o.append(a)
p.append(b)
for i in range(m):
a,b=map(int,input().split())
q.append(a)
r.append(b)
for i in range(n):
mind=kyori(a[i],b[i],c[0],d[0])
minn=1
for j in range(m-1):
a=kyori(a[i],b[i],c[j+1],d[j+1])
if a<mind:
mind=a
minn=j+2
print(minn) |
s273762090 | p03774 | u393512980 | 1553197256 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 359 | n,m=map(int,input().split())
a_b=[list(map(int,input().split()) for _ in range(n)]
c_d=sorted([list(map(int,input().split()) for _ in range(m)])
for i in range(n):
res=1
d=abs(a_b[i][0]-c_d[0][0])+abs(a_b[i][1]-c_d[0][1])
for j in range(m):
t=abs(a_b[i][0]-c_d[j][0])+abs(a_b[i][1]-c_d[j][1])
if t<d:
d=t
res=j+1
print(res)
|
s650116479 | p03774 | u782654209 | 1553112479 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 261 | N,M=map(int,input().split(' '))
S = [list(map(int,input().split(' '))) for i in range(N)]
C = [list(map(int,input().split(' '))) for i in range(M)]
for i in range(N):
l = [abs(S[i][0]-C[i][0])+abs(S[i][1]-C[i][1]) for i in range(M)]
print(l.index(min(l))+1) |
s799285808 | p03774 | u785578220 | 1552020778 | Python | PyPy3 (2.4.0) | py | Runtime Error | 193 | 38256 | 268 | a,b = map(int, input().split())
x = []
m =19999999999999
for i in range(a):
ta , tb = map(int, input().split())
x.append([ta,tb])
for i in range(b):
ta , tb = map(int, input().split())
for x,y in x:
m = min(m,abs(x-ta)+abs(y-tb))
print(m) |
s487679727 | p03774 | u619197965 | 1551977208 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 414 | n,m=[int(i) for i in input().split()]
ab=[]
cd=[]
for i in range(n):
a,b=[int(j) for j in input().split()]
ab.append((a,b))
for i in range(m):
c,d=[int(j) for j in input().split()]
cd.append((c,d))
for i in range(n):
mini=10000000
for j in range(m):
dis=abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1])
if mini>dis:
mini=dis
point=j+1
print(point) |
s209966488 | p03774 | u945418216 | 1551396216 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 343 | n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m
for i in range(n):
aa[i], bb[i] = map(int, input().split())
for i in range(m):
cc[i], dd[i] = map(int, input().split())
distance = []
for i in range(n):
d = [abs(aa[i] - cc[j]) + abs(bb[i] - dd[j]) for j in range(m)]
print(d.index(min(d))+1) |
s012097489 | p03774 | u945418216 | 1551396117 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 425 | n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m
for i in range(n):
aa[i], bb[i] = map(int, input().split())
for i in range(m):
cc[i], dd[i] = map(int, input().split())
distance = []
for i in range(n):
d = []
for j in range(m):
d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
d.append(d_)
distance.append(d)
for d in distance:
print(d.index(min(d))+1) |
s309855670 | p03774 | u945418216 | 1551396095 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3316 | 501 | n,m = map(int, input().split())
aa = [0] * m
bb = [0] * m
cc = [0] * m
dd = [0] * m
for i in range(n):
aa[i], bb[i] = map(int, input().split())
for i in range(m):
cc[i], dd[i] = map(int, input().split())
distance = []
for i in range(n):
d = []
for j in range(m):
d_ = abs(aa[i] - cc[j]) + abs(bb[i] - dd[j])
d.append(d_)
print('({}, {}) ({}, {}) :{}'.format(aa[i],bb[i],cc[j],dd[j], d_))
distance.append(d)
for d in distance:
print(d.index(min(d))+1) |
s621089888 | p03774 | u518064858 | 1550786037 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 378 | 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)
|
s572655960 | p03774 | u072606168 | 1550191771 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 429 | n,m=map(int,input())
a,b,c,d=[],[],[],[]
for i in range(n):
o = list(map(int, input().split()))
a.append(o[0])
b.append(o[1])
for i in range(m):
o = list(map(int, input().split()))
c.append(o[0])
d.append(o[1])
s = []
for i in range(n):
g = float('inf')
h = 0
for j in range(m):
if g > abs(a[i]-c[j])+abs(b[i]-d[j]):
g = abs(a[i]-c[j])+abs(b[i]-d[j])
h = j+1
s.append(h)
for i in s:
print(i) |
s309003558 | p03774 | u268318377 | 1550159197 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 437 | n,m = map(int,input().split())
AB = [[int(i) for i in input().split()] for j in range(n)]
CD = [[int(k) for k in input().split()] for l in range(n)]
ans = [0]*n
for ab in AB:
a,b = ab[0],ab[1]
distance = 1000000000
for cd in CD:
c,d = cd[0], cd[1]
if distance > abs(a-c) + abs(b-d):
distance = abs(a-c) + abs(b-d)
ans[AB.index(ab)] = CD.index(cd)+1
for _ in ans:
print(_) |
s622834021 | p03774 | u268318377 | 1550159128 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 436 | n,m = map(int,input().split())
AB = [[int(i) for i in input().split()] for j in range(n)]
CD = [[int(k) for k in input().split()] for l in range(n)]
ans = [0]*n
for ab in AB:
a,b = ab[0],ab[1]
distance = 100000000
for cd in CD:
c,d = cd[0], cd[1]
if distance > abs(a-c) + abs(b-d):
distance = abs(a-c) + abs(b-d)
ans[AB.index(ab)] = CD.index(cd)+1
for _ in ans:
print(_) |
s272372766 | p03774 | u020604402 | 1549984521 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 490 | students = []
for _ in range(N):
l = list(map(int,input().split()))
students.append(l)
check_points = []
for _ in range(M):
l = list(map(int,input().split()))
check_points.append(l)
minimum_points = 0
for person in students:
minimum = 10**10
for i in range(len(check_points)):
d=abs(person[0]-check_points[i][0])+abs(person[1]-check_points[i][1])
if minimum > d:
minimum = d
minimum_points = i
print(minimum_points+1)
|
s182097336 | p03774 | u853900545 | 1548973674 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 250 | 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(m):
l[i] = abs(a[i][0]-c)+abs(a[i][1]-d)
print(l.index(min(l))+1) |
s862703145 | p03774 | u364741711 | 1548436615 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3060 | 293 | n,m=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]
for i in range(n):
li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
print(li_distance.index(min(li_distance)+1))
|
s743519450 | p03774 | u735763891 | 1546290302 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 484 | def abc057_b():
from math import inf
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 i in range(n):
tmp_index = 0
d = inf
for j in range(m):
tmp_d = abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
if tmp_d < d:
tmp_index = j
d = tmp_d
print(tmp_index + 1)
abc057_b() |
s965572466 | p03774 | u026155812 | 1544251953 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 386 | N, M = [int(i) for i in input().split().strip()]
A = [[int(i) for i in input().split().strip()] for j in range(N)]
C = [[int(i) for i in input().split().strip()] 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) |
s743159720 | p03774 | u601522790 | 1542918338 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 387 | n,m = map(int,input().split())
A = []
B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
q,r = map(int,input().split())
if m == 0:
temp = abs(A[i] - q) + abs(B[i] - r)
ans = 0
elif abs(A[i] - q) + abs(B[i] - r) < temp:
temp = abs(A[i] - q) + abs(B[i] - r)
ans = j
print(ans)
|
s969674298 | p03774 | u601522790 | 1542918251 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 387 | n,m = map(int,input().split())
A = []
B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m == 0:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = 0
elif abs(A[i] - x) + abs(B[i] - y) < temp:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = j
print(ans)
|
s118848321 | p03774 | u601522790 | 1542918233 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 388 | n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m == 0:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = 0
elif abs(A[i] - x) + abs(B[i] - y) < temp:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = j
print(ans)
|
s036047236 | p03774 | u601522790 | 1542918149 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 386 | n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m == 0:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = 0
if abs(A[i] - x) + abs(B[i] - y) < temp:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = j
print(ans)
|
s117496474 | p03774 | u601522790 | 1542918100 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 385 | n,m = map(int,input().split())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m = 0:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = 0
if abs(A[i] - x) + abs(B[i] - y) < temp:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = j
print(ans)
|
s925393733 | p03774 | u601522790 | 1542918022 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 377 | n,m = map(int,input())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m = 0:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = 0
if abs(A[i] - x) + abs(B[i] - y) < temp:
temp = abs(A[i] - x) + abs(B[i] - y)
ans = j
print(ans)
|
s218030771 | p03774 | u601522790 | 1542917942 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 338 | n,m = map(int,input())
A = [], B = []
ans = 0
temp = 0
for i in range(n):
x,y = map(int,input().split())
A.append(x)
B.append(y)
for j in range(m):
x,y = map(int,input().split())
if m = 0:
temp = (abs(A[i] - x) + abs(B[i] - y))
ans = 0
if (abs(A[i] - x) + abs(B[i] - y)) < temp:
ans = j
print(ans)
|
s959269260 | p03774 | u985076807 | 1542757528 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 968 | # https://beta.atcoder.jp/contests/abc057/tasks/abc057_b
class Point(object):
def __init__(self, x, y):
self.x = int(x)
self.y = int(y)
@staticmethod
def manhattan(p1, p2):
return abs(p1.x - p2.x) + abs(p1.y - p2.y)
def __str__(self):
return f'(x, y) = ({self.x}, {self.y})'
def solve():
# Max(n, m) = (50, 50) => 50 * 2
n, m = map(int, input().split())
students = []
for _ in range(n):
students.append(Point(*input().split()))
checkpoints = []
for _ in range(m):
checkpoints.append(Point(*input().split()))
for student in students:
min_dist = 4 * (10 ** 8)
min_index = 1
for index, cp in enumerate(checkpoints):
manhattan = Point.manhattan(student, cp)
if min_dist > manhattan:
min_dist = manhattan
min_index = index + 1
print(min_index)
if __name__ == '__main__':
solve()
|
s255014004 | p03774 | u047535298 | 1542605319 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 422 | N, M = map(int, input().split())
students = [list(map(int, input().split())) for i in range(N)]
checkpoints = [list(map(int, input().split())) for i in range(M)]
for s in students:
min_distance = 2 * 10**8 + 1
for i, c in enumerate(checkpoints):
distance = abs(s[0] - c[0]) + abs(s[1]- c[1])
if min_distance > distance:
min_distance = distance
point = i+1
print(point) |
s697547736 | p03774 | u166696759 | 1542499238 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 317 | n, m = map(int, input().split())
A = [(a, b) for a, b in map(int, input().split())]
C = [(c, d) for c, d in map(int, input().split())]
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(j)
|
s914072623 | p03774 | u853900545 | 1539881662 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 355 | 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[i])+abs(b[i]-d[i])
for i in range(n):
print(D[i].index(min(D[i]))+1) |
s329544098 | p03774 | u853900545 | 1539881545 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 355 | 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]-b[i])+abs(c[i]-d[i])
for i in range(n):
print(D[i].index(min(D[i]))+1) |
s616214316 | p03774 | u513081876 | 1538939475 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 452 | N, M =map(int, input().split())
a, b = [0]*N, [0]*N
c, d = [0]*N, [0]*N
ans = []
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):
length = 10**9
ind = 0
for j in range(M):
man = abs(a[i] - c[j])+abs(b[i] - d[j])
if length > man:
length = man
ind = j+1
ans.append(ind)
for i in ans:
print(i) |
s093015656 | p03774 | u094565093 | 1537393259 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 480 | N,M=map(int,input().split())
S=[list(map(int,input().split())) for i in range(N)]
T=[list(map(int,input().split())) for i in range(M)]
for i in range(N):
x1=S[i][0]
y1=S[i][1]
x2=T[0][0]
y2=T[0][1]
min=abs(x1-x2)+abs(y1-y2)
x1=S[i][0]
y1=S[i][1]
for j in range(M-1,-1,-1):
x2=T[j][0]
y2=T[j][1]
if min>=abs(x1-x2)+abs(y1-y2):
min=abs(x1-x2)+abs(y1-y2)
R[i]=j+1
for i in range(len(R)):
print(R[i]) |
s028509077 | p03774 | u366644013 | 1535218923 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 352 | n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
mindis = 10 ** 9
for j in range(m):
dis = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
if mindis > dis:
p = j+1
mindis = dis
print(p) |
s963777468 | p03774 | u362560965 | 1535061471 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 423 | N,M = map(int,input().split())
a = [0 for i in range(N)]
b = [0 for i in range(N)]
c = [0 for i in range(M)]
d = [0 for i in range(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):
for j in range(M):
dist = []
tmp = abs(a[i]-c[i]) + abs(b[i]-d[i])
dist.append(tmp)
print(dist.index(min(dist))) |
s385805653 | p03774 | u759651152 | 1533744207 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 607 | #-*-coding:utf-8-*-
def main():
n, m = map(int, input().split())
ab_list = []
cd_list = []
for _ in range(n):
ab_list.append(list(map(int, input().split())))
for _ in range(m):
cd_list.append(list(map(int, input().split())))
for i in ab_list:
min_distance = 2 * 10 ** 8
for j in range(m):
distance = abs(i[0] - cd_list[j][0]) + abs(i[1] - cd_list[j][1])
if distance < min_distance:
min_distance = distance
min_coord = j + 1
print(min_coord)
if __name__ == '__main__':
main() |
s776299936 | p03774 | u232852711 | 1533091753 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 354 | n, m = list(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:
min_dist = 2*10**8
for i, (c, d) in enumerate(cd):
dist = abs(a-c)+abs(b-d)
if dist < min_dist:
min_dist = dist
ans = i+1
print(ans) |
s111597774 | p03774 | u407730443 | 1532632965 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 610 | 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)]
min_distance_point = [None for i in range(m)]
for i, ab_i in enumerate(ab):
a_i, b_i = ab_i
min_distance_num = 10000
min_distance = 100000000000
for j, cd_i in enumerate(cd):
c_i, d_i = cd_i
distance = abs(a_i - c_i) + abs(b_i - d_i)
if distance < min_distance:
min_distance = distance
min_distance_num = j+1
min_distance_point[i] = min_distance_num
[print(x) for x in min_distance_point] |
s292064821 | p03774 | u004025573 | 1531886799 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 478 | n, m = map(int, input().split())
N_ab = []
M_cd = []
for i in range(n):
a, b = map(int, input().split())
N_ab.append([a, b])
for i in range(n):
c, d = map(int, input().split())
M_cd.append([c, d])
for i in range(n):
Mi = abs(N_ab[i][0]-M_cd[0][0]) + abs(N_ab[i][1]-M_cd[0][1])
#print(Mi)
num = 0
for j in range(1, m):
tmp = abs(N_ab[i][0]-M_cd[j][0]) + abs(N_ab[i][1]-M_cd[j][1])
#print(tmp)
if tmp<Mi:
Mi=tmp
num=j
print(num+1) |
s640387688 | p03774 | u445863230 | 1530220860 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 466 | 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):
if k>abs(int(kpop[i][1])-int(jpop[j][1]))+abs(int(kpop[i][2])-int(jpop[j][2])):
z=j
k=abs(int(kpop[i][1])-int(jpop[j][1]))+abs(int(kpop[i][2])-int(jpop[j][2]))
print(z)
|
s112123741 | p03774 | u482969053 | 1529665902 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 416 | N, M = list(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(N)]
for ab_i in ab:
min_j = -1
min_manh = float('inf')
for j, cd_j in enumerate(cd):
if min_manh > abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1]):
min_manh = abs(ab_i[0]-cd_j[0])+abs(ab_i[1]-cd_j[1])
min_j = j+1
print(min_j) |
s682034354 | p03774 | u857259336 | 1528367732 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1105 | // header {{{
#include <bits/stdc++.h>
using namespace std;
// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF INT_MAX/3
#define LLINF LLONG_MAX/3
#define MOD (1000000007LL)
#define MODA(a, b) a=((a)+(b))%MOD
#define MODP(a, b) a=((a)*(b))%MOD
#define inc(i, l, r) for(int i=(l);i<(r);i++)
#define dec(i, l, r) for(int i=(r)-1;i>=(l);i--)
#define pb push_back
#define se second
#define fi first
#define mset(a, b) memset(a, b, sizeof(a))
using LL = long long;
using G = vector<vector<int>>;
int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}
int main() {
cin.tie(0);ios::sync_with_stdio(false);
int n, m;cin >> n >> m;
vector<int> a(n), b(n), c(n), d(n);
inc(i, 0, n) cin >> a[i] >> b[i];
inc(i, 0, m) cin >> c[i] >> d[i];
inc(i, 0, n){
int min = INT_MAX;
int ans = 0;
inc(j, 0, m){
if(abs(a[i]-c[j])+abs(b[i]-d[j]) < min){
ans = j;
min = abs(a[i]-c[j])+abs(b[i]-d[j]);
}
}
cout << ans+1 << endl;
}
return 0;
}
|
s443443502 | p03774 | u136395536 | 1528270095 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 648 | 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[j]))
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[j]))
for i in range(N):
print(distance[i]) |
s438228619 | p03774 | u409064224 | 1526505609 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 230 | #-*- coding:utf-8 -*-
a = list(map(int,input().split()))
num = 0
for i in range(a[0] + a[1]):
num += 1
list_{}.format(num) = []
list_{}.format(num).append(list(map(int,input().split())))
print(list_{}.format(num))
|
s800706870 | p03774 | u027622859 | 1522875093 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 437 | 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
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) |
s618789978 | p03774 | u027622859 | 1522874985 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 437 | 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
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+1
print(check_point) |
s221743897 | p03774 | u027622859 | 1522874902 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 437 | 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
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+1
print(check_point) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.