結果
問題 | No.2594 Mix shake!! |
ユーザー | hitonanode |
提出日時 | 2023-12-04 02:44:07 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 403 ms / 2,000 ms |
コード長 | 2,658 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 12,032 KB |
最終ジャッジ日時 | 2024-09-27 09:05:54 |
合計ジャッジ時間 | 12,822 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
11,648 KB |
testcase_01 | AC | 39 ms
11,648 KB |
testcase_02 | AC | 41 ms
11,648 KB |
testcase_03 | AC | 37 ms
11,776 KB |
testcase_04 | AC | 38 ms
11,648 KB |
testcase_05 | AC | 38 ms
11,776 KB |
testcase_06 | AC | 38 ms
11,648 KB |
testcase_07 | AC | 37 ms
11,776 KB |
testcase_08 | AC | 37 ms
11,776 KB |
testcase_09 | AC | 37 ms
11,776 KB |
testcase_10 | AC | 38 ms
11,648 KB |
testcase_11 | AC | 38 ms
11,648 KB |
testcase_12 | AC | 39 ms
11,648 KB |
testcase_13 | AC | 38 ms
11,776 KB |
testcase_14 | AC | 39 ms
11,776 KB |
testcase_15 | AC | 38 ms
11,648 KB |
testcase_16 | AC | 39 ms
11,648 KB |
testcase_17 | AC | 39 ms
11,648 KB |
testcase_18 | AC | 40 ms
11,648 KB |
testcase_19 | AC | 39 ms
11,648 KB |
testcase_20 | AC | 38 ms
11,648 KB |
testcase_21 | AC | 37 ms
11,648 KB |
testcase_22 | AC | 38 ms
11,648 KB |
testcase_23 | AC | 40 ms
11,648 KB |
testcase_24 | AC | 37 ms
11,776 KB |
testcase_25 | AC | 38 ms
11,648 KB |
testcase_26 | AC | 38 ms
11,648 KB |
testcase_27 | AC | 38 ms
11,648 KB |
testcase_28 | AC | 38 ms
11,776 KB |
testcase_29 | AC | 37 ms
11,648 KB |
testcase_30 | AC | 38 ms
11,648 KB |
testcase_31 | AC | 38 ms
11,776 KB |
testcase_32 | AC | 55 ms
11,648 KB |
testcase_33 | AC | 71 ms
11,776 KB |
testcase_34 | AC | 388 ms
11,904 KB |
testcase_35 | AC | 399 ms
12,032 KB |
testcase_36 | AC | 400 ms
12,032 KB |
testcase_37 | AC | 396 ms
12,032 KB |
testcase_38 | AC | 398 ms
12,032 KB |
testcase_39 | AC | 389 ms
12,032 KB |
testcase_40 | AC | 394 ms
11,904 KB |
testcase_41 | AC | 399 ms
12,032 KB |
testcase_42 | AC | 399 ms
11,904 KB |
testcase_43 | AC | 399 ms
11,904 KB |
testcase_44 | AC | 403 ms
12,032 KB |
testcase_45 | AC | 392 ms
11,904 KB |
testcase_46 | AC | 394 ms
12,032 KB |
testcase_47 | AC | 396 ms
11,904 KB |
testcase_48 | AC | 397 ms
11,904 KB |
testcase_49 | AC | 403 ms
11,904 KB |
testcase_50 | AC | 391 ms
11,904 KB |
testcase_51 | AC | 391 ms
11,904 KB |
testcase_52 | AC | 391 ms
12,032 KB |
testcase_53 | AC | 394 ms
11,904 KB |
testcase_54 | AC | 38 ms
11,648 KB |
testcase_55 | AC | 38 ms
11,648 KB |
testcase_56 | AC | 37 ms
11,776 KB |
testcase_57 | AC | 37 ms
11,648 KB |
testcase_58 | AC | 37 ms
11,648 KB |
testcase_59 | AC | 38 ms
11,776 KB |
testcase_60 | AC | 37 ms
11,648 KB |
testcase_61 | AC | 38 ms
11,648 KB |
testcase_62 | AC | 37 ms
11,776 KB |
testcase_63 | AC | 37 ms
11,648 KB |
testcase_64 | AC | 36 ms
11,648 KB |
testcase_65 | AC | 38 ms
11,648 KB |
testcase_66 | AC | 41 ms
11,648 KB |
testcase_67 | AC | 38 ms
11,648 KB |
testcase_68 | AC | 40 ms
11,648 KB |
testcase_69 | AC | 38 ms
11,648 KB |
testcase_70 | AC | 40 ms
11,776 KB |
testcase_71 | AC | 38 ms
11,648 KB |
testcase_72 | AC | 37 ms
11,648 KB |
testcase_73 | AC | 38 ms
11,776 KB |
testcase_74 | AC | 37 ms
11,648 KB |
testcase_75 | AC | 37 ms
11,648 KB |
testcase_76 | AC | 36 ms
11,648 KB |
testcase_77 | AC | 37 ms
11,648 KB |
testcase_78 | AC | 38 ms
11,648 KB |
testcase_79 | AC | 37 ms
11,648 KB |
testcase_80 | AC | 40 ms
11,648 KB |
testcase_81 | AC | 37 ms
11,776 KB |
testcase_82 | AC | 41 ms
11,648 KB |
testcase_83 | AC | 38 ms
11,648 KB |
testcase_84 | AC | 38 ms
11,648 KB |
testcase_85 | AC | 39 ms
11,648 KB |
testcase_86 | AC | 37 ms
11,648 KB |
testcase_87 | AC | 38 ms
11,648 KB |
ソースコード
#!/usr/bin/env python3 # これはちゃんと AC のはず from fractions import Fraction def make_convex_slope(A: list[int], B: list[int]) -> list[tuple[int, int]]: x, y = 0, 0 ret: list[tuple[int, int]] = [(0, 0)] seq = sorted([(Fraction(b, a), a, b) for a, b in zip(A, B)]) for _, a, b in seq: x += a y += b ret.append((x, y)) return ret def trajectory_solve( A: list[int], B: list[int], C: list[int], D: list[int] ) -> tuple[bool, list[tuple[Fraction, Fraction]]]: assert len(A) == len(B) == len(C) == len(D) assert sum(A) == sum(C) assert sum(B) == sum(D) assert min(A + B + C + D) >= 1 assert max(A + B + C + D) <= 100000000000000000 lo_polyline = make_convex_slope(A, B) hi_polyline = make_convex_slope(C, D) for (x0, y0), (x1, y1) in zip(lo_polyline, lo_polyline[1:]): for x, y in hi_polyline: if (x1 - x0) * (y - y0) - (y1 - y0) * (x - x0) < 0: return False, [] assert lo_polyline[0] == hi_polyline[0] == (0, 0) assert lo_polyline[-1] == hi_polyline[-1] == (sum(A), sum(B)) nx, ny = Fraction(0), Fraction(0) trajectory: list[tuple[Fraction, Fraction]] = [(nx, ny)] while (nx, ny) != lo_polyline[-1]: s = Fraction(1 << 60) # slope for px, py in hi_polyline: if px <= nx: continue s = min(s, Fraction(py - ny, px - nx)) assert s < Fraction(1 << 60) next_x = Fraction(sum(A)) for (px, py), (qx, qy) in zip(lo_polyline, lo_polyline[1:]): s2 = Fraction(qy - py, qx - px) if s2 <= s: continue # y = s * (x - nx) + ny と y = s2 * (x - px) + py の交点 # sx - s nx + ny == s2 x - s2 px + py # (s - s2) x == s nx - ny - s2 px + py next_x = min(next_x, (s * nx - ny - s2 * px + py) / (s - s2)) ny += s * (next_x - nx) nx = next_x trajectory.append((nx, ny)) ans: bool = False if len(trajectory) - 1 < len(A): ans = True else: abidx = sorted([(Fraction(B[i], A[i]), i) for i in range(len(A))]) cdidx = sorted([(Fraction(D[i], C[i]), i) for i in range(len(B))]) if [i for _, i in abidx] == [i for _, i in cdidx]: ans = True return ans, trajectory if __name__ == "__main__": input() A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) D = list(map(int, input().split())) ret, trajectory = trajectory_solve(A=A, B=B, C=C, D=D) print("Yes" if ret else "No")