結果
| 問題 | No.3601 Queen Dist Sum with One Wall |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-07-24 23:24:36 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 549 ms / 2,000 ms |
| + 421µs | |
| コード長 | 994 bytes |
| 記録 | |
| コンパイル時間 | 242 ms |
| コンパイル使用メモリ | 96,496 KB |
| 実行使用メモリ | 94,200 KB |
| 最終ジャッジ日時 | 2026-07-24 23:25:08 |
| 合計ジャッジ時間 | 11,146 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
from sys import stdin
input = stdin.readline
def rotate():
global H, W, h, w, x, y
h, w = w, H-h+1
x, y = y, H-x+1
H, W = W, H
for _ in range(int(input())):
H, W, h, w, x, y = map(int, input().split())
while not (h <= x and w < y):
rotate()
cnt1 = (h-1)+(H-h)+(w-1)+min(h-1, w-1)+min(H-h, w-1)+min(h-1, W-w)
if h == x:
cnt1 += y-w-1
else:
cnt1 += W-w
if h-w == x-y:
cnt1 += y-w-1
else:
cnt1 += min(H-h, W-w)
ans = cnt1+2*(H*W-2-cnt1)
if h == x:
# 壁の横の3の分を足す
ans += W-y
# 斜め→縦
r = min(w+max(h-1, H-h), W)
if y < r:
ans -= r-y
y = r
# 斜め→斜め
l = y+1
if (x+y)%2 == (h+w)%2: l += 1
r = w+max((h-1)*2, (H-h)*2)
if W < r:
r = W
if (h+W)%2 != (h+w)%2:
r -= 1
if l <= r:
ans -= (r-l)//2+1
print(ans)
detteiuu