結果
問題 | No.2968 Final MIGISITA Strike |
ユーザー | 👑 rin204 |
提出日時 | 2024-11-16 23:02:44 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,199 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 121,496 KB |
最終ジャッジ日時 | 2024-11-16 23:03:09 |
合計ジャッジ時間 | 23,635 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,736 KB |
testcase_01 | AC | 35 ms
52,736 KB |
testcase_02 | AC | 36 ms
52,736 KB |
testcase_03 | AC | 36 ms
52,864 KB |
testcase_04 | AC | 37 ms
52,864 KB |
testcase_05 | AC | 36 ms
52,736 KB |
testcase_06 | AC | 36 ms
53,120 KB |
testcase_07 | AC | 36 ms
52,992 KB |
testcase_08 | AC | 36 ms
52,736 KB |
testcase_09 | AC | 36 ms
52,864 KB |
testcase_10 | AC | 372 ms
99,520 KB |
testcase_11 | AC | 436 ms
107,324 KB |
testcase_12 | AC | 214 ms
86,016 KB |
testcase_13 | WA | - |
testcase_14 | AC | 203 ms
86,400 KB |
testcase_15 | AC | 709 ms
110,448 KB |
testcase_16 | AC | 576 ms
107,320 KB |
testcase_17 | WA | - |
testcase_18 | AC | 373 ms
96,192 KB |
testcase_19 | WA | - |
testcase_20 | AC | 591 ms
107,496 KB |
testcase_21 | WA | - |
testcase_22 | AC | 345 ms
89,064 KB |
testcase_23 | AC | 699 ms
117,788 KB |
testcase_24 | AC | 668 ms
111,412 KB |
testcase_25 | AC | 774 ms
121,496 KB |
testcase_26 | WA | - |
testcase_27 | AC | 452 ms
95,796 KB |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 165 ms
78,932 KB |
testcase_37 | AC | 281 ms
86,788 KB |
testcase_38 | AC | 286 ms
87,608 KB |
testcase_39 | AC | 283 ms
87,168 KB |
testcase_40 | AC | 376 ms
92,560 KB |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 416 ms
96,824 KB |
testcase_45 | WA | - |
testcase_46 | AC | 488 ms
103,240 KB |
testcase_47 | WA | - |
testcase_48 | AC | 397 ms
98,272 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 326 ms
90,688 KB |
testcase_52 | AC | 319 ms
92,160 KB |
testcase_53 | WA | - |
testcase_54 | AC | 207 ms
81,888 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 418 ms
96,692 KB |
testcase_59 | AC | 281 ms
87,216 KB |
testcase_60 | AC | 241 ms
84,608 KB |
testcase_61 | WA | - |
testcase_62 | WA | - |
testcase_63 | AC | 387 ms
94,888 KB |
testcase_64 | AC | 36 ms
52,608 KB |
testcase_65 | WA | - |
testcase_66 | WA | - |
ソースコード
def ext_gcd(a, b): """ return (x, y, gcd(a, b)) s.t. ax + by = gcd(a, b) """ if b == 0: return 1, 0, a else: y, x, g = ext_gcd(b, a % b) return x, y - (a // b) * x, g from math import gcd MOD = 998244353 h, w, n, m, s, c, X, Y = map(int, input().split()) pos = [] for _ in range(n): x, y, a = map(int, input().split()) y = w - y pos.append((x, y, a)) for _ in range(m): x, y, a = map(int, input().split()) y = w - y pos.append((x, y, -a)) Y = w - Y lcm = 4 * h * w // gcd(2 * h, 2 * w) add = [] c0 = 0 c1 = 0 for x, y, a in pos: x_, y_, g = ext_gcd(2 * h, 2 * w) diff = (X - Y) - (x - y) if diff % g == 0: xx = x_ * (diff // g) to_x = x + xx * 2 * h add.append(((to_x - X) % lcm, a)) if a > 0: c0 += 1 else: c1 += 1 diff = (X - Y) - (x - (2 * w - y)) if diff % g == 0: xx = x_ * (diff // g) to_x = x + xx * 2 * h add.append(((to_x - X) % lcm, a)) if a > 0: c0 += 1 else: c1 += 1 diff = (X - Y) - ((2 * h - x) - y) if diff % g == 0: xx = x_ * (diff // g) to_x = 2 * h - x + xx * 2 * h add.append(((to_x - X) % lcm, a)) if a > 0: c0 += 1 else: c1 += 1 diff = (X - Y) - ((2 * h - x) - (2 * w - y)) if diff % g == 0: xx = x_ * (diff // g) to_x = 2 * h - x + xx * 2 * h add.append(((to_x - X) % lcm, a)) if a > 0: c0 += 1 else: c1 += 1 add.sort(key=lambda x: x[0]) tot = 0 min_ = 0 add.append((lcm, 0)) bt = -1 for t, x in add: tot -= (t - 1 + X) // h * c tot -= (t - 1 + Y) // w * c tot += (bt + X) // h * c tot += (bt + Y) // w * c min_ = min(min_, tot) tot += x bt = t if s + min_ > 0 and tot >= 0: print(-1) exit() loop = max(0, (s + min_) // abs(tot)) c0 *= loop c1 *= loop s += loop * tot bt = -1 for t, x in add: diff = 0 diff -= (t - 1 + X) // h * c diff -= (t - 1 + Y) // w * c diff += (bt + X) // h * c diff += (bt + Y) // w * c if diff + s <= 0: lef = bt rig = t while rig - lef > 1: mid = (rig + lef) // 2 diff = 0 diff -= (mid + X) // h * c diff -= (mid + Y) // w * c diff += (bt + X) // h * c diff += (bt + Y) // w * c if diff + s <= 0: rig = mid else: lef = mid xx = (X + rig) % (2 * h) yy = (Y + rig) % (2 * w) if xx >= h: xx = 2 * h - xx if yy >= w: yy = 2 * w - yy yy = w - yy c0 %= MOD c1 %= MOD print(xx, yy, c0, c1) break bt = t s += diff s += x if x > 0: c0 += 1 else: c1 += 1 if s <= 0: xx = (X + t) % (2 * h) yy = (Y + t) % (2 * w) if xx >= h: xx = 2 * h - xx if yy >= w: yy = 2 * w - yy yy = w - yy c0 %= MOD c1 %= MOD print(xx, yy, c0, c1) break