結果
| 問題 |
No.5009 Draw A Convex Polygon
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2022-12-02 01:59:48 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,211 bytes |
| コンパイル時間 | 66 ms |
| 実行使用メモリ | 352,576 KB |
| スコア | 0 |
| 平均クエリ数 | 2.00 |
| 最終ジャッジ日時 | 2022-12-02 01:59:56 |
| 合計ジャッジ時間 | 7,191 ms |
|
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 1 |
ソースコード
import sys
import numpy as np
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def from_read(dtype=np.int64):
return np.fromstring(read().decode(), dtype=dtype, sep=' ')
def from_readline(dtype=np.int64):
return np.fromstring(readline().decode(), dtype=dtype, sep=' ')
def solve_max():
THRESH = 35242
MAX = 1000
XY, n = np.empty((10**6, 2), np.int64), 0
for x in range(1, MAX + 1):
for y in range(0, MAX + 1):
if abs(x) + abs(y) > MAX:
continue
if x == y == 0:
continue
if np.gcd(x, y) > 1:
continue
XY[n], n = (x, y), n + 1
XY[n], n = (-y, x), n + 1
XY = XY[:n]
Z = np.abs(XY).sum(axis=1)
XY = XY[Z < MAX]
XY = np.concatenate((XY, -XY), axis=0)
sort_key = np.arctan2(XY[:,1], XY[:,0])
argsort = np.argsort(sort_key)
XY = XY[argsort]
points = np.cumsum(XY, axis=0)
points[:,0] -= points[:,0].min()
points[:,1] -= points[:,1].min()
return points
def main(N):
points = solve_max().ravel().tolist()
print(N)
print(" ".join(map(str, points)))
main(10 ** 6)
maspy