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
s322646715
p02289
u112247126
1487833103
Python
Python3
py
Runtime Error
0
0
1106
import sys from numpy import inf def insert(heap, key): heap.append(-inf) heapIncreaseKey(heap, key) def parent(i): return (i - 1) // 2 def heapIncreaseKey(heap, key): heap[len(heap) - 1] = key i = len(heap) - 1 while i > 0 and heap[parent(i)] < heap[i]: heap[i], heap[parent(i)] = hea...
s215176537
p02289
u112247126
1487833266
Python
Python3
py
Runtime Error
0
0
1101
import sys from numpy import inf def insert(heap, key): heap.append(-inf) heapIncreaseKey(heap, key) def parent(i): return (i - 1) // 2 def heapIncreaseKey(heap, key): heap[len(heap) - 1] = key i = len(heap) - 1 while i > 0 and heap[parent(i)] < heap[i]: heap[i], heap[parent(i)] = hea...
s481653155
p02289
u546285759
1492335251
Python
Python3
py
Runtime Error
0
0
335
import bisect from collections import deque maxv = 0 l = deque() while True: order = input() if order == "end": break tmp = order.split() if len(tmp) > 1: v = int(tmp[1]) bisect.insort(l, v) maxv = l[-1] else: print(maxv) l.pop() maxv = l[-1] i...
s281568507
p02289
u370086573
1494575770
Python
Python3
py
Runtime Error
0
0
1102
import sys heap = [0] NIL = -1 def parent(i): return i // 2 def left(i): return 2 * i def right(i): return 2 * i + 1 def insert(key): H = len(heap) - 1 heap.append(NIL) heapIncreaseKey(H, key) def heapIncreaseKey(i, key): if key < heap[i]: return False heap[i] = key ...
s397655964
p02289
u370086573
1494576402
Python
Python3
py
Runtime Error
0
0
1102
def parent(i): return i // 2 def left(i): return 2 * i def right(i): return 2 * i + 1 def insert(key): heap.append(NIL) H = len(heap) - 1 heapIncreaseKey(H, key) def heapIncreaseKey(i, key): if key < heap[i]: return False heap[i] = key while i > 1 and heap[parent(i)] ...
s415356911
p02289
u990398499
1499326550
Python
Python3
py
Runtime Error
0
0
1407
# ?§£???2 from math import inf from math import floor def maxheapfi(i): global H global A l = 2 * (i + 1) - 1 r = 2 * (i + 1) if l < H and A[l] > A[i-1] : largest = l else: largest = i if r < H and A[r] > A[largest] : largest = r if largest != i: ...
s195803451
p02289
u990398499
1499326711
Python
Python3
py
Runtime Error
0
0
1404
# ?§£???2 from math import inf from math import floor def maxheapfi(i): global H global A l = 2 * (i + 1) - 1 r = 2 * (i + 1) if l < H and A[l] > A[i-1] : largest = l else: largest = i if r < H and A[r] > A[largest] : largest = r if largest != i: ...
s464530114
p02289
u990398499
1499328051
Python
Python3
py
Runtime Error
0
0
1450
# ?§£???2 from math import inf from math import floor def maxheapfi(i): global H global A l = 2 * (i) + 1 r = 2 * (i +1) if l < H and A[l] > A[i] : largest = l else: largest = i if r < H and A[r] > A[largest] : largest = r #print('largest',largest) if la...
s532818009
p02289
u990398499
1499328140
Python
Python3
py
Runtime Error
0
0
1450
# ?§£???2 from math import inf from math import floor def maxheapfi(i): global H global A l = 2 * (i) + 1 r = 2 * (i +1) if l < H and A[l] > A[i] : largest = l else: largest = i if r < H and A[r] > A[largest] : largest = r #print('largest',largest) if la...
s267641186
p02289
u990398499
1499328184
Python
Python3
py
Runtime Error
0
0
1438
from math import inf from math import floor def maxheapfi(i): global H global A l = 2 * (i) + 1 r = 2 * (i +1) if l < H and A[l] > A[i] : largest = l else: largest = i if r < H and A[r] > A[largest] : largest = r #print('largest',largest) if largest != i...
s929604579
p02289
u796784914
1500703270
Python
Python
py
Runtime Error
0
0
1037
from collections import deque def main(): q =deque() H = 0 for i in range(int(2e+06)): cmd = map(str,raw_input().split()) if cmd[0] == "insert": q.append(int(cmd[1])) H += 1 increase(q,H) elif cmd[0] == "extract": print q.popleft() ...
s572494384
p02289
u616085665
1500707541
Python
Python
py
Runtime Error
0
0
329
def main(): q = [] while(True): cmd = map(str,raw_input().split()) if cmd[0] == "insert": q.append()=int(cmd[1]) elif cmd[0] == "extract": ret = max(q) print ret q.remove(ret) else: break if __name__ == "__main__": ...
s107432913
p02289
u024715419
1510120413
Python
Python3
py
Runtime Error
0
0
177
a = [] while True: inp = input() if inp[0] == "i": a.append(int(inp[7:])) elif inp[0] == "e": a.sort() print(a.pop()) else: break
s003647558
p02289
u662418022
1517738189
Python
Python3
py
Runtime Error
0
0
1490
# -*- coding: utf-8 -*- def parent(i): return i // 2 def left(i): return 2 * i def right(i): return 2 * i + 1 class MaxHeap(list): def __init__(self, H=0): list.__init__(self) self.H = H self[:] = [None] * (H+1) def insert(self, key): self.H += 1 self.a...
s376060139
p02289
u426534722
1518447436
Python
Python3
py
Runtime Error
0
0
781
def maxHeapify(A, i, n): l = i * 2 + 1 r = i * 2 + 2 if l < n and A[l] > A[i]: largest = l else: largest = i if r < n and A[r] > A[largest]: largest = r if largest != i: A[i], A[largest] = A[largest], A[i] maxHeapify(A, largest) def insert(S, k): S.app...
s155263126
p02289
u150984829
1519622530
Python
Python3
py
Runtime Error
0
0
408
def h(i): l=2*i;r=l+1 if r<H: if A[i]<A[l]: if A[l]<A[r]:A[i],A[r]=A[r],A[i];h(r) else:A[i],A[l]=A[l],A[i];h(l) elif A[i]<A[r]:A[i],A[r]=A[r],A[i];h(r) elif l<H and A[i]<A[l]:A[i],A[l]=A[l],A[i];h(l) H=0 A=[0] for a in iter(input,'end'): if a[0]=='i': H+=1;A+=[int(a[7:])];k=H while k>1 and A[k//2]<A[k...
s730710765
p02289
u150984829
1519625234
Python
Python3
py
Runtime Error
0
0
149
import sys from heapq import * H,O=[],'' for e in sys.stdin: if'i'==e[0]:heappush(H,-int(e[7:])) elif't'==e[2]:O+=f'{-heappop(H)}\n') print(O[-1])
s135724706
p02289
u150984829
1519625791
Python
Python3
py
Runtime Error
0
0
161
import sys from heapq import * H,O=[],[] for e in sys.stdin: t=e[1] if'n'==t:heappush(H,-int(e[7:])) elif'x'==t:O+=[-heappop(H)] print('\n'.join(map(str,O)))
s674250930
p02289
u150984829
1519625848
Python
Python3
py
Runtime Error
0
0
161
import sys from heapq import * H,O=[],[] for e in sys.stdin: c=e[1] if'n'==c:heappush(H,-int(e[7:])) elif'x'==c:O+=[-heappop(H)] print('\n'.join(map(str,O)))
s138561262
p02289
u126478680
1525855936
Python
Python3
py
Runtime Error
0
0
1679
class PriorityQueue(): def __init__(self): self.heap = [] self.num_node = 0 def max_heapify(self, i): l = (i+1)*2-1 r = (i+1)*2 largest = i if l < self.num_node and self.heap[l] > self.heap[i]: largest = l else: largest = i ...
s245387382
p02289
u126478680
1525855995
Python
Python3
py
Runtime Error
0
0
1679
class PriorityQueue(): def __init__(self): self.heap = [] self.num_node = 0 def max_heapify(self, i): l = (i+1)*2-1 r = (i+1)*2 largest = i if l < self.num_node and self.heap[l] > self.heap[i]: largest = l else: largest = i ...
s040756571
p02289
u269391636
1526898206
Python
Python3
py
Runtime Error
0
0
170
a = [] while(True): x = input().split() if x[0] == "end": quit() elif x[0] == "insert": a.append(x[1]) a.sort(reversed = True) else: print(a[0]) del(a[0])
s549721304
p02289
u684241248
1528521521
Python
Python3
py
Runtime Error
0
0
1315
# -*- coding: utf-8 -*- INF = -10**10 queue = [-1] def insert(queue, key): h = len(queue) - 1 queue.append(INF) heap_increase_key(queue, h + 1, key) def heap_increase_key(queue, i, key): if key < queue[i]: raise ValueError('The new key is smaller than the present key') queue[i] = key ...
s976379575
p02289
u782850731
1380230153
Python
Python
py
Runtime Error
0
0
1409
#!/usr/bin/env python from __future__ import division, print_function from sys import stdin, maxint from array import array MININT = -1 - maxint def max_heapify(a, i, heap_size): L = 2*i R = 2*i + 1 if L <= heap_size and a[L] > a[i]: largest = L else: largest = i if R <= heap_size...
s967195321
p02290
u540744789
1426163250
Python
Python
py
Runtime Error
20
4316
772
x1,y1,x2,y2=map(float,raw_input().split(" ")) if y1==y2 or x1==x2: if y1==y2: t0=0 if x1==x2: t1=0 else: t0=(y2-y1)/(x2-x1) b0=y1-t0*x1 t1=-(x2-x1)/(y2-y1) for i in xrange(int(raw_input())): px,py=map(float,raw_input().split(" ")) if t0==0 or t1==0: if t0==0: ...
s923946035
p02290
u988834390
1502884545
Python
Python3
py
Runtime Error
0
0
349
points=[] points=int(input().split()) p1,q1,p2,q2=points[0:3] def search_x(x,y): return ((q2-q1)*x+q1*((q2-q1)*(q2-q1))/(p2-p1))/((q2-q1)*(q2-q1)/(p2-p1)+(p2-p1)) n=int(input()) for i in range(n): point=[] point=int(input().split()) x=search_x(point[0],point[1]) y=(x-q1)*(q2-q1)/(p2-p1)-q1 pr...
s853389965
p02290
u988834390
1502884622
Python
Python3
py
Runtime Error
0
0
290
points=[] points=int(input().split()) p1,q1,p2,q2=points[0:3] n=int(input()) for i in range(n): point=[] point=int(input().split()) x=((q2-q1)*x+q1*((q2-q1)*(q2-q1))/(p2-p1))/((q2-q1)*(q2-q1)/(p2-p1)+(p2-p1)) y=(x-q1)*(q2-q1)/(p2-p1)-q1 print('{} {}'.format(x,y))
s290150229
p02290
u126478680
1526238441
Python
Python3
py
Runtime Error
20
5684
900
import math class Point(): def __init__(self, x=None, y=None): self.x = x self.y = y class Vector(): def __init__(self, x, y): self.x = x self.y = y self.abs = math.sqrt(x*x + y*y) def constant_multipled(self, c): return Vector(self.x*c, self.y*c) def ...
s030926130
p02290
u572424947
1376578382
Python
Python
py
Runtime Error
10
4296
725
class Point(): def __init__(self, x, y): self.x = x self.y = y output_list = [] init_point = map(float, raw_input().split()) p0 = Point(init_point[0], init_point[1]) p1 = Point(init_point[2], init_point[3]) q = int(raw_input()) datalist = [map(float, raw_input().split()) for i in range(q)] #p0--p1 : y=ax...
s355148711
p02291
u988834390
1502885083
Python
Python3
py
Runtime Error
0
0
721
""" p1p2: (y-y1)(x2-x1)=(x-x1)(y2-y1) p vertical: (y2-y1)(y-py)+(x2-x1)(x-px)=0 y=(x-x1)(y2-y1)/(x2-x1)-y1 (y2-y1)((x-x1)(y2-y1)/(x2-x1)-y1-py)+(x2-x1)(x-px)=0 (x-x1)(y2-y1)^2/(x2-x1)+(y2-y1)(y1+py)+(x2-x1)x-(x2-x1)px=0 x((y2-y1)^2/(x2-x1)+(x2-x1))-x1((y2-y1)^2/(x2-x1)-(x2-x1)px=0 x=((x2-x1)...
s217160128
p02291
u548155360
1529920481
Python
Python3
py
Runtime Error
0
0
1078
# coding=utf-8 import numpy as np from math import sqrt def vector_abs(vect): return sqrt(sum([element**2 for element in vect])) def direction_unit_vector(p_from, p_to): d_vector = p_to - p_from d_u_vector = d_vector/vector_abs(d_vector) return d_u_vector def projection(origin, line_from, line_to)...
s243349467
p02291
u548155360
1529921156
Python
Python3
py
Runtime Error
0
0
1419
# coding=utf-8 from math import sqrt, fsum def inner_product(vect1, vect2): return math.fsum([(v1_el*v2_el) for v1_el, v2_el in zip(vect1, vect2)]) def vector_abs(vect): return sqrt(sum([element**2 for element in vect])) def direction_unit_vector(p_from, p_to): d_vector = [(xt - xf) for xt, xf in zip(...
s683041859
p02292
u487861672
1551589956
Python
Python3
py
Runtime Error
60
7300
6212
#! /usr/bin/env python3 from typing import List, Tuple from math import sqrt from enum import Enum EPS = 1e-10 def float_equal(x: float, y: float) -> bool: return abs(x - y) < EPS class PointLocation(Enum): COUNTER_CLOCKWISE = 1 CLOCKWISE = 2 ONLINE_BACK = 3 ONLINE_FRONT = 4 ON_SEGMENT = 5...
s810354808
p02292
u487861672
1551590028
Python
Python3
py
Runtime Error
60
7304
6211
#! /usr/bin/env python3 from typing import List, Tuple from math import sqrt from enum import Enum EPS = 1e-10 def float_equal(x: float, y: float) -> bool: return abs(x - y) < EPS class PointLocation(Enum): COUNTER_CLOCKWISE = 1 CLOCKWISE = 2 ONLINE_BACK = 3 ONLINE_FRONT = 4 ON_SEGMENT = 5...
s263924425
p02292
u548155360
1529922589
Python
Python3
py
Runtime Error
20
5616
1249
# coding=utf-8 def cross_product(vect1, vect2): return vect1[0]*vect2[1] - vect1[1]*vect2[0] def vector_plus(vect1, vect2): return [el1 + el2 for el1, el2 in zip(vect1, vect2)] def vector_minus(vect1, vect2): return [el1 - el2 for el1, el2 in zip(vect1, vect2)] def vector_product(vect1, vect2): ...
s632504868
p02293
u711765449
1485351517
Python
Python3
py
Runtime Error
0
0
836
n = int(input()) for i in range(n): x0,y0,x1,y1,x2,y2,x3,y3 = map(float,input().split()) if x1 - x0 == 0: if x3 -x2 == 0: print('2') elif y3 - y2 == 0: print('1') else: print('0') elif x3 - x2 == 0: if y1 - y0 == 0: print('1') ...
s378277471
p02293
u988834390
1502886500
Python
Python3
py
Runtime Error
0
0
277
points=[] n=int(input()) points=input().split() p0,q0,p1,q1,p2,q2,p3,q3=points for i in range(n): if (q1 - q0) * (p2 - p3) == (q2 - q3) * (p1 - p0): print(2) elif (q1 - q0) * (q2 - q3) + (p1 - p0) * (p2 - p3) == 1: print(1) else: print(0)
s688728991
p02294
u279605379
1503550641
Python
Python3
py
Runtime Error
0
0
1054
class Line: def __init__(self,p1,p2): if p1[1] < p2[1]:self.s=p2;self.e=p1 elif p1[1] > p2[1]:self.s=p1;self.e=p2 else: if p1[0] < p2[0]:self.s=p1;self.e=p2 else:self.s=p2;self.e=p1 def dot(a,b):return a[0]*b[0] + a[1]*b[1] def cross(a,b):return a[0]*b[1] - a[1]*b[0] ...
s558557702
p02294
u126478680
1527475610
Python
Python3
py
Runtime Error
20
5672
1351
import math class Point(): def __init__(self, x, y): self.x = x self.y = y class Segment(): def __init__(self, x1, y1, x2, y2): self.p1 = Point(x1, y1) self.p2 = Point(x2, y2) self.slope = None self.intersept = None if self.p1.x == self.p2.x: ...
s443355786
p02296
u022407960
1480593150
Python
Python3
py
Runtime Error
0
0
1421
# !/usr/bin/env python # -*- coding: utf-8 -*- """ input: 4 5 1 0 1 2 0 2 3 1 2 -5 1 3 1 2 3 2 output: INF 0 -5 -3 OR input: 4 6 0 0 1 2 0 2 3 1 2 -5 1 3 1 2 3 2 3 1 0 output: NEGATIVE CYCLE """ import sys from math import isinf def generate_adj_table(_v_info): for each in _v_info: source, target, co...
s497723373
p02296
u279605379
1503627679
Python
Python3
py
Runtime Error
0
0
2163
class Line: def __init__(self,p1,p2): if p1[1] < p2[1]:self.s=p2;self.e=p1 elif p1[1] > p2[1]:self.s=p1;self.e=p2 else: if p1[0] < p2[0]:self.s=p1;self.e=p2 else:self.s=p2;self.e=p1 def cross(a,b):return a[0]*b[1] - a[1]*b[0] def dot(a,b):return a[0]*b[0]+a[1]*b[1] d...
s734971644
p02297
u279605379
1503643390
Python
Python3
py
Runtime Error
0
0
222
n = int(input()) P =[] s = 0 for i in range(n):P.append([int(i) for i in input().split()]) P.append(P[0]) for i in range(n): a = P[i][0] ; b = P[i][1]; c = P[i+1][0] ; P[i+1][1] s += a * d - b * c print(abs(s)*0.5)
s906876742
p02297
u279605379
1503643720
Python
Python3
py
Runtime Error
0
0
245
n = int(input()) P =[] s = 0 x0,y0 = [int(i) for i in input().split()] for i in range(n): x,y = [int(i) for i in input().split()] P.append([x-x0,y-y0]) for i in range(n-2): s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0] print(abs(s)*0.5)
s096938662
p02297
u279605379
1503644545
Python
Python3
py
Runtime Error
0
0
186
n = int(input()) P =[] s = 0 x,y = for _ in range(n):P.append([int(i) for i in input().split()]) P.append(P[0]) for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0] print(s*0.5)
s239468209
p02297
u279605379
1503646038
Python
Python3
py
Runtime Error
0
0
183
n = int(input()) P =[] s = 0 for _ in range(n):P.append([int(-i) for i in input().split()]) P.append(P[0]) for j in range(n):s += P[j][1]*P[j+1][0] - P[j][0] * P[j+1][1] print(s*0.5)
s608355396
p02297
u279605379
1503646346
Python
Python3
py
Runtime Error
0
0
166
n = int(input()) x = range(n) P =[] s = 0 for _ in x:P += [int(i) for i in input().split()] P+=P[0] for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0] print(s*0.5)
s469875526
p02297
u279605379
1503646429
Python
Python3
py
Runtime Error
0
0
168
n = int(input()) x = range(n) P =[] s = 0 for _ in x:P += [[int(i) for i in input().split()]] P+=P[0] for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0] print(s*0.5)
s063086391
p02297
u279605379
1503646481
Python
Python3
py
Runtime Error
0
0
171
n = int(input()) x = range(n) P =[] s = 0 for _ in x:P.append([int(i) for i in input().split()]) P+=P[0] for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0] print(s*0.5)
s841716791
p02297
u279605379
1503646597
Python
Python3
py
Runtime Error
0
0
168
n = int(input()) x = range(n) P =[] s = 0 for _ in x:P += [[int(i) for i in input().split()]] P+=P[0] for j in x:s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0] print(s*0.5)
s199495014
p02297
u279605379
1503648021
Python
Python3
py
Runtime Error
0
0
153
x=range(int(input())) P=[] _=0 for _ in x:P+=[[int(i) for i in input().split()]] P+=[P[0]] for j in x:s+=P[j][0]*P[j+1][1]-P[j][1]*P[j+1][0] print(s*0.5)
s421786670
p02297
u279605379
1503649688
Python
Python3
py
Runtime Error
0
0
186
x=range(int(input())) f=lambda a,b,c,d : a*d - b*c P=[] for _ in x:P+=[[int(i) for i in input().split()]] _=0 P+=[P[0]] for j in x:_+=f(P[j][0],P[j][1],,P[j+1][0]P[j+1][1]) print(_*0.5)
s369091115
p02298
u279605379
1503973949
Python
Python3
py
Runtime Error
0
0
273
def cross(a,b):return a[0]*b[1] - a[1]*b[0] def dif(a,b):return [x-y for x,y in zip(a,b)] x = range(int(input())) t = 1 P,Q = [],[] for _ in x:P+=[[int(i) for i in input().split()]] for i in x:Q+=[dif(P[i],P[i-1])] for i in x:if cross(Q[i-1],Q[i]) < 0: t *= False print(t)
s066412379
p02300
u022407960
1480734769
Python
Python3
py
Runtime Error
0
0
2007
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 7 2 1 0 0 1 2 2 2 4 2 1 3 3 3 output: 5 0 0 2 1 4 2 3 3 1 3 """ import sys from operator import attrgetter EPS = 1e-9 def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def check_ccw...
s699744478
p02300
u279605379
1504489964
Python
Python3
py
Runtime Error
0
0
1125
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] ...
s204205963
p02300
u279605379
1504490065
Python
Python3
py
Runtime Error
0
0
1125
#CGL_4-A Convex Polygon - Convex Hull def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],...
s994966776
p02300
u279605379
1504490231
Python
Python3
py
Runtime Error
0
0
1130
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] ...
s131088327
p02300
u279605379
1504490493
Python
Python3
py
Runtime Error
0
0
1105
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): phU = [P[0],P[1]] for p in P[2:]:...
s002084068
p02300
u279605379
1504490671
Python
Python3
py
Runtime Error
0
0
1101
import heapq def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]...
s286781274
p02300
u279605379
1504490895
Python
Python3
py
Runtime Error
0
0
1137
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = deque([P[0],P...
s766811066
p02300
u279605379
1504490998
Python
Python3
py
Runtime Error
0
0
1167
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = deque(P[0],P[...
s516087077
p02300
u279605379
1504491892
Python
Python3
py
Runtime Error
0
0
1197
from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = deque([]) ...
s516750710
p02300
u279605379
1504491970
Python
Python3
py
Runtime Error
0
0
1235
#CGL_4-A Convex Polygon - Convex Hull from collections import deque def isCLKWISE(ph): a = [ph[-1][0]-ph[-3][0],ph[-1][1]-ph[-3][1]] b = [ph[-2][0]-ph[-3][0],ph[-2][1]-ph[-3][1]] crs = a[0]*b[1] - a[1]*b[0] if crs < 0 : return False else : return True def ConvexHullScan(P): ...
s042271882
p02300
u279605379
1504493544
Python
Python3
py
Runtime Error
0
0
956
import sys def isCLKWISE(ph): if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): ...
s840246335
p02300
u279605379
1504493687
Python
Python3
py
Runtime Error
0
0
958
import sys def isCLKWISE(ph): if (ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0 : return False else : return True def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): ...
s014657536
p02300
u279605379
1504498077
Python
Python3
py
Runtime Error
0
0
913
def isCLKWISE(ph): return ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) >= 0 def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): if isCLKWISE(phU) : break ...
s114454075
p02300
u279605379
1504498377
Python
Python3
py
Runtime Error
0
0
912
def isCLKWISE(ph): return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P): P.sort() phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): if isCLKWISE(phU) : break ...
s078657193
p02300
u279605379
1504498733
Python
Python3
py
Runtime Error
0
0
943
from collections import deque def isCLKWISE(ph): return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): i...
s043546654
p02300
u279605379
1504498778
Python
Python3
py
Runtime Error
0
0
939
from collections import deque def isCLKWISE(ph): return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P): P = sorted(P) phU = [P[0],P[1]] for p in P[2:]: phU.append(p) while(True): i...
s420149968
p02300
u279605379
1504501572
Python
Python3
py
Runtime Error
0
0
891
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P) : P = sorted(P) phU = [] phU.append(P[0]) phU.append(P[1]) for p in P[2:] : phU.append(p) if isCLKWISE(phU) : continue while(True): del p...
s940070028
p02300
u279605379
1504501752
Python
Python3
py
Runtime Error
0
0
899
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P) : P = sorted(P) phU = [] phU.append(P[0]) phU.append(P[1]) for p in P[2:] : phU.append(p) if isCLKWISE(phU) : continue while(True)???: de...
s966678289
p02300
u279605379
1504501778
Python
Python3
py
Runtime Error
0
0
938
#sort ??§?????????????????????????????? def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0) def ConvexHullScan(P) : P = sorted(P) phU = [] phU.append(P[0]) phU.append(P[1]) for p in P[2:] : phU.append(p) if isCLKWISE...
s828181379
p02300
u559070407
1515975366
Python
Python3
py
Runtime Error
0
0
1315
# O(NlgN) time # build lower hull and upper hull in clockwise, concatenate them get convex hull def convexHull(points): assert len(points) > 0 points = sorted(set(points)) # build lower hull lower = [] for p in points: # cross(o, a, b) <= 0 not clockwise while len(lower) >= 2 and cross(lower[-2], ...
s268940821
p02301
u072053884
1492579255
Python
Python3
py
Runtime Error
40
8188
1102
# Cross product def cross(p1, p2, q1, q2): p = p2 - p1 q = q2 - q1 return p.real * q.imag - p.imag * q.real # Rotating calipers def convex_diameter(points, n): points.append(points[0]) p0 = points[0] p1 = points[1] for i, (q1, q2) in enumerate(zip(points[1:], points[2:]), start=1): ...
s083174513
p02301
u072053884
1492580173
Python
Python3
py
Runtime Error
60
8276
1101
# Cross product def cross(p1, p2, q1, q2): p = p2 - p1 q = q2 - q1 return p.real * q.imag - p.imag * q.real # Rotating calipers def convex_diameter(points, n): points.append(points[0]) p0 = points[0] p1 = points[1] for i, (q1, q2) in enumerate(zip(points[1:], points[2:]), start=1): ...
s114305041
p02301
u260980560
1499962573
Python
Python3
py
Runtime Error
0
0
1578
from math import sqrt # ?????? def cross(P0, P1, P2): x0, y0 = P0; x1, y1 = P1; x2, y2 = P2 x1 -= x0; x2 -= x0 y1 -= y0; y2 -= y0 return x1*y2 - x2*y1 # ?????? def dot(P0, P1, P2): x0, y0 = P0; x1, y1 = P1; x2, y2 = P2 x1 -= x0; x2 -= x0 y1 -= y0; y2 -= y0 return x1*x2 + y1*y2 # 2????...
s054255167
p02301
u260980560
1499962788
Python
Python3
py
Runtime Error
0
0
1469
from math import sqrt def cross(P0, P1, P2): x0, y0 = P0; x1, y1 = P1; x2, y2 = P2 x1 -= x0; x2 -= x0 y1 -= y0; y2 -= y0 return x1*y2 - x2*y1 def dot(P0, P1, P2): x0, y0 = P0; x1, y1 = P1; x2, y2 = P2 x1 -= x0; x2 -= x0 y1 -= y0; y2 -= y0 return x1*x2 + y1*y2 def dist2(P0, P1): x0...
s814248362
p02302
u567380442
1428742800
Python
Python3
py
Runtime Error
0
0
1727
from sys import stdin readline = stdin.readline from enum import Enum direction = Enum('direction', 'CCW CW CAB ABC ACB') class vector: def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def ccw(a, b, c): b -= a ...
s673194337
p02302
u567380442
1428743094
Python
Python3
py
Runtime Error
0
0
1748
from sys import stdin readline = stdin.readline from enum import Enum direction = Enum('direction', 'CCW CW CAB ABC ACB') class vector: def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def ccw(a, b, c): b -= a ...
s912846154
p02302
u567380442
1428749083
Python
Python3
py
Runtime Error
0
0
1792
from sys import stdin readline = stdin.readline from enum import Enum direction = Enum('direction', 'CCW CW CAB ABC ACB') class vector: def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def ccw(a, b, c): b -= a ...
s520636952
p02302
u567380442
1428749547
Python
Python3
py
Runtime Error
0
0
1785
from sys import stdin readline = stdin.readline from enum import Enum direction = Enum('direction', 'CCW CW CAB ABC ACB') class vector: def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def ccw(a, b, c): b -= a ...
s851294381
p02302
u567380442
1428749931
Python
Python3
py
Runtime Error
0
0
1831
from sys import stdin readline = stdin.readline from enum import Enum direction = Enum('direction', 'CCW CW CAB ABC ACB') class vector: def cross(a, b): return a.real * b.imag - a.imag * b.real def dot(a, b): return a.real * b.real + a.imag * b.imag def ccw(a, b, c): b -= a ...
s081566786
p02302
u260980560
1467437882
Python
Python
py
Runtime Error
10
6484
1041
n = input() ps = [map(int, raw_input().split()) for i in xrange(n)] def intersection(p1, p2, q1, q2): dx0 = p2[0] - p1[0] dy0 = p2[1] - p1[1] dx1 = q2[0] - q1[0] dy1 = q2[1] - q1[1] a = dy0*dx1; b = dy1*dx0; c = dx0*dx1; d = dy0*dy1 if a == b: return None x = (a*p1[0] - b*q1[0] + c*(q1[1] - ...
s907422917
p02302
u797673668
1473068673
Python
Python3
py
Runtime Error
20
7832
1017
def cross(a, b): return a.real * b.imag - a.imag * b.real def cross_point(c, d): l = d - c v1 = cross(lv, l) v2 = cross(lv, lt - c) return c + v2 / v1 * l n = int(input()) points = [complex(*map(int, input().split())) for _ in range(n)] point0 = points.pop(0) points.append(point0) q = int(input...
s440759152
p02302
u072053884
1493205490
Python
Python3
py
Runtime Error
30
7776
1963
# cross point def cross(c1, c2): return c1.real * c2.imag - c1.imag * c2.real def cross_point(p1, p2, p3, p4): # p1 and p2 are points on a segment. # p3 and p4 are points on the other segment. base = p4 - p3 hypo1 = p1 - p3 hypo2 = p2 - p3 d1 = cross(base, hypo1) / abs(base) d2 = cross...
s393985228
p02303
u567380442
1428802533
Python
Python3
py
Runtime Error
0
0
818
from sys import stdin readline = stdin.readline import operator def norm(self): return abs(self) def closest_pair(p): m = 0 p.sort(key=operator.attrgetter('real')) d = float('inf') for i in range(1, len(p)): for j in reversed(range(m, i)): tmp = abs(p[j] - p[i]) i...
s877197473
p02303
u567380442
1428803134
Python
Python3
py
Runtime Error
0
0
839
from sys import stdin import operator readline = stdin.readline def norm(self): return abs(self) def closest_pair(p): m = 0 p.sort(key=operator.attrgetter('real')) d = float('inf') for i in range(1, len(p)): for j in reversed(range(m, i)): tmp = p[i] - p[j] if d <...
s095914161
p02303
u657035709
1435966997
Python
Python
py
Runtime Error
20
4604
3665
# #### CLOSEST PAIR O(N LOG N) ALGORITHM #### # # points should be unique, otherwise the closest pair would be the repeated points # also this will only find 1 pair with the smallest distance, in case there are multiple pairs with this same minimum distance #import time #start = time.time() def halve(coord): # spli...
s705593661
p02303
u657035709
1435967283
Python
Python
py
Runtime Error
30
4604
3743
# #### CLOSEST PAIR O(N LOG N) ALGORITHM #### # # points should be unique, otherwise the closest pair would be the repeated points # also this will only find 1 pair with the smallest distance, in case there are multiple pairs with this same minimum distance #import time #start = time.time() def halve(coord): # spli...
s953797478
p02303
u072053884
1492011599
Python
Python3
py
Runtime Error
30
7664
2201
import itertools def _get_min_distance(points): min_d = 400 for p1, p2 in itertools.combinations(points, 2): min_d = min(min_d, abs(p1 - p2)) return min_d # Search based on x axis def closest_pair_distance_x(points): n = len(points) if n <= 3: return _get_min_distance(points) e...
s128007785
p02303
u797673668
1492589378
Python
Python3
py
Runtime Error
20
7816
882
from operator import attrgetter from itertools import combinations keys = [attrgetter('real'), attrgetter('imag')] def solve(points, axis): l = len(points) if l < 20: return min(abs(p2 - p1) for p1, p2 in combinations(points, 2)) m = n // 2 pl, pr = points[:m], points[m:] key, rkey = keys...
s401015495
p02303
u797673668
1492589429
Python
Python3
py
Runtime Error
30
7756
924
import sys sys.setrecursionlimit(10000) from operator import attrgetter from itertools import combinations keys = [attrgetter('real'), attrgetter('imag')] def solve(points, axis): l = len(points) if l < 20: return min(abs(p2 - p1) for p1, p2 in combinations(points, 2)) m = n // 2 pl, pr = p...
s586227548
p02303
u928329738
1512309233
Python
Python3
py
Runtime Error
0
0
310
import numpy as np n = int(input()) p = [] for i in range(n): p.append(tuple(map(float,input().split()))) d = [] min = 999999999999 for i in range(n-1): for j in range(i+1,n): a = ((p[j][0]-p[i][0])**2+(p[j][1]-p[i][1])**2) if a < min: min = a print(round(np.sqrt(min),11))
s365542492
p02304
u629780968
1546487871
Python
Python3
py
Runtime Error
40
6348
3367
from enum import IntEnum class Action(IntEnum): ADD = 1 SEARCH = 2 REMOVE = 3 class Color(IntEnum): BLACK=0 RED=1 @staticmethod def flip(c): return [Color.RED,Color.BLACK][c.value] class Node: __slots__ = ('value','left','right','color','valid') def __init__(self,value): self.value=value ...
s438916365
p02304
u011621222
1526486091
Python
Python3
py
Runtime Error
0
0
3155
lass AvlTree(BinarySearchTree): '''An extension t the BinarySearchTree data structure which strives to keep itself balanced ''' def _put(self,key,val,currentNode): if key < currentNode.key: if current.Node.hasLeftChild(): self._put(key,val,currentNode.leftChild) ...
s373101074
p02305
u265136581
1523264165
Python
Python3
py
Runtime Error
0
0
488
cx1, cy1, r1 = map(float, raw_input().split()) cx2, cy2, r2 = map(float, raw_input().split()) import math distance = math.sqrt( math.pow(cx1-cx2, 2) + math.pow(cy1-cy2, 2) ) rsum = r1 + r2 rmax = math.max(r1, r2) rmin = math.min(r1, r2) import sys if distance > rsum: print(4) elif abs(distance - rsum) < sys.float_...
s216292788
p02305
u825008385
1523809516
Python
Python3
py
Runtime Error
0
0
3819
# Single Source Shortest Path class node(): def __init__(self, v, cost): self.v = v self.cost = cost infty = 999999999 dict_c = {} [vertex, edge, r] = list(map(int, input("").split())) root_c = [node(r, 0)] final_c = [infty for i in range(vertex)] final_c[r] = 0 for i in range(edge): [e1, e2, ...
s888419766
p02305
u893844544
1523843446
Python
Python3
py
Runtime Error
0
0
290
c1x,c1y,c1r = [int(i) for i in input().split()] c2x,c2y,c2r = [int(i) for i in input().split()] d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2)) s = c1r + c2r if d > s: print 4 else if d == c: print 3 else if d > 2*s: print 2 else if d == 2*s: print 1 else: print 0
s208727312
p02305
u893844544
1523843610
Python
Python3
py
Runtime Error
0
0
295
c1x,c1y,c1r = [int(i) for i in input().split()] c2x,c2y,c2r = [int(i) for i in input().split()] d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2)) s = c1r + c2r if d > s: print(4) else if d == c: print(3) else if d > 2*s: print(2) else if d == 2*s: print(1) else: print(0)
s570427412
p02305
u893844544
1523843659
Python
Python3
py
Runtime Error
0
0
286
c1x,c1y,c1r = [int(i) for i in input().split()] c2x,c2y,c2r = [int(i) for i in input().split()] d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2)) s = c1r + c2r if d > s: print(4) elif d == c: print(3) elif d > 2*s: print(2) elif d == 2*s: print(1) else: print(0)
s004096707
p02305
u893844544
1523843751
Python
Python3
py
Runtime Error
20
5668
299
import math c1x,c1y,c1r = [int(i) for i in input().split()] c2x,c2y,c2r = [int(i) for i in input().split()] d = math.sqrt(pow(c1x-c2x, 2) + pow(c1y-c2y, 2)) s = c1r + c2r if d > s: print(4) elif d == c: print(3) elif d > 2*s: print(2) elif d == 2*s: print(1) else: print(0)