結果

問題 No.202 1円玉投げ
ユーザー niyarin
提出日時 2016-10-04 18:44:12
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 1,614 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 198,676 KB
最終ジャッジ日時 2024-12-22 10:45:07
合計ジャッジ時間 132,952 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

N = input()
inputs = [map(int,raw_input().split(" ")) for i in range(N)]

class AABB:
    def __init__(self):
        pass
    def marge(ab1,ab2):
        ret = AABB()
        ret.left = min(ab1.left,ab2.left)
        ret.right = max(ab1.right,ab2.right)
        ret.up = min(ab1.up,ab2.up)
        ret.down = max(ab1.down,ab2.down)
        ret.children = [ab1,ab2]
        return ret


    def nyrn(self,x,y):
        self.left = x - 10
        self.right = x + 10
        self.up = y - 10
        self.down = y + 10
        self.x = x
        self.y = y
        self.children = -1

    def search(self,cx,cy):
        if cx+10 > self.left and cx-10 < self.right:
            if cy-10<self.down and cy+10 > self.up:
                if self.children == -1:
                    return  (self.x-cx)**2+(self.y-cy)**2 < 400
                else:
                    for c in self.children:
                        if c.search(cx,cy):
                            return True


aabb = AABB()
aabb.nyrn(inputs[0][0],inputs[0][1])
ans = 1
nyrns = [[] for i in range(17)]
nyrns[0].append(aabb)


for x,y in inputs[1:]:
    flag = False
    for i in range(17):
        for c in nyrns[i]:
            if c.search(x,y):
                flag = True
    

    if flag:
        pass
    else:
       ans+=1 
       new_aabb = AABB()
       new_aabb.nyrn(x,y)
       nyrns[0].append(new_aabb)

       for i in range(17):
           while len(nyrns[i] )>2:
               xx = nyrns[i].pop(0)
               yy = nyrns[i].pop(0)
               zz = AABB.marge(xx,yy)
               nyrns[i+1].append(zz)



        
print ans   

0