結果

問題 No.5009 Draw A Convex Polygon
ユーザー titiatitia
提出日時 2022-12-02 05:30:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,084 bytes
コンパイル時間 863 ms
実行使用メモリ 141,024 KB
スコア 0
平均クエリ数 168837.00
最終ジャッジ日時 2022-12-02 05:30:57
合計ジャッジ時間 3,966 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt

M=10**9
ANS=[(0,M)]
N=200000

while len(ANS)<N and ANS[-1][0]<10**9-100:
    NG=ANS[-1][0]+1000
    OK=min(M,NG+127)

    while OK>NG+1:
        mid=(OK+NG)//2

        y=round(sqrt(M*M-mid*mid))
        if y<ANS[-1][1]-100:
            OK=mid
        else:
            NG=mid

    ANS.append((OK,round(sqrt(M*M-OK*OK))))

from operator import itemgetter
P=ANS

P.sort(key=itemgetter(1)) # 一番左下の点から始める。
P.sort(key=itemgetter(0))

# 上側凸包と下側凸包
Q1=[]

def outer_product(x,y,z,w):
    return x*w-y*z
 
for x,y in P:
    while True:
        if len(Q1)<2:
            break
 
        s,t=Q1[-1]
        u,v=Q1[-2]
 
        if outer_product(u-s,v-t,x-u,y-v)<0:
            Q1.pop()
        else:
            break
 
    Q1.append((x,y))

Q=Q1

ANS=[]

for i in range(len(Q)):
    x,y=Q[i]
    z,w=Q[-1-i]
    ANS.append(str(x)+" "+str(y))
    ANS.append(str(-z)+" "+str(w))
    ANS.append(str(-x)+" "+str(-y))
    ANS.append(str(z)+" "+str(-w))

n=10**6
ANS=ANS[:n]
print(len(ANS),flush=True)
print("\n".join(ANS),flush=True)
0