結果
| 問題 | 
                            No.48 ロボットの操縦
                             | 
                    
| コンテスト | |
| ユーザー | 
                             lam6er
                         | 
                    
| 提出日時 | 2025-03-20 21:08:23 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,156 bytes | 
| コンパイル時間 | 281 ms | 
| コンパイル使用メモリ | 82,080 KB | 
| 実行使用メモリ | 54,244 KB | 
| 最終ジャッジ日時 | 2025-03-20 21:09:08 | 
| 合計ジャッジ時間 | 2,326 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 WA * 7 | 
ソースコード
X = int(input())
Y = int(input())
L = int(input())
if X == 0 and Y == 0:
    print(0)
    exit()
D_x = abs(X)
D_y = abs(Y)
X_dir_num = 1 if X >= 0 else 3  # 1 for East, 3 for West
Y_dir_num = 0 if Y >= 0 else 2  # 0 for North, 2 for South
x_commands = (D_x + L - 1) // L
y_commands = (D_y + L - 1) // L
def get_rotation_cost(current, target):
    diff = (target - current) % 4
    return min(diff, 4 - diff)
# Case 1: Y first, then X
case1_rot = 0
if D_x != 0:
    if D_y == 0:
        # Rotate from North to X_dir_num
        case1_rot = get_rotation_cost(0, X_dir_num)
    else:
        # Rotate from Y_dir_num to X_dir_num
        case1_rot = get_rotation_cost(Y_dir_num, X_dir_num)
case1 = y_commands + case1_rot + x_commands
# Case 2: X first, then Y
case2_rot1 = 0
if D_x != 0:
    case2_rot1 = get_rotation_cost(0, X_dir_num)
case2_rot2 = 0
if D_y != 0:
    if D_x != 0:
        case2_rot2 = get_rotation_cost(X_dir_num, Y_dir_num)
    else:
        # Current direction is North (0), rotate to Y_dir_num
        case2_rot2 = get_rotation_cost(0, Y_dir_num)
case2 = x_commands + case2_rot1 + y_commands + case2_rot2
print(min(case1, case2))
            
            
            
        
            
lam6er