結果
問題 | No.2760 not fair position game |
ユーザー |
|
提出日時 | 2024-05-17 22:12:33 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,715 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,984 KB |
実行使用メモリ | 698,716 KB |
最終ジャッジ日時 | 2024-05-17 22:12:37 |
合計ジャッジ時間 | 3,794 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
61,072 KB |
testcase_01 | AC | 37 ms
55,856 KB |
testcase_02 | MLE | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
ソースコード
from collections import deque def play_game(N, K): # Directions: up, down, left, right directions = [(-1, 0), (1, 0), (0, -1), (0, 1)] # Create an empty grid grid = [[None] * N for _ in range(N)] # Initialize Alice's starting point (K-1, 0) and Bob's starting point (K-1, N-1) grid[K-1][0] = 'A' grid[K-1][N-1] = 'B' # Initialize queues for BFS-like approach alice_queue = deque([(K-1, 0)]) bob_queue = deque([(K-1, N-1)]) # Counters for cells colored by Alice and Bob alice_count = 1 bob_count = 1 # Flag to track whose turn is next: True for Alice, False for Bob alice_turn = True # Perform moves until 2*N*N turns are exhausted or no more moves for _ in range(2 * N * N): if alice_turn: if not alice_queue: break x, y = alice_queue.popleft() for dx, dy in directions: nx, ny = x + dx, y + dy if 0 <= nx < N and 0 <= ny < N and grid[nx][ny] is None: grid[nx][ny] = 'A' alice_queue.append((nx, ny)) alice_count += 1 else: if not bob_queue: break x, y = bob_queue.popleft() for dx, dy in directions: nx, ny = x + dx, y + dy if 0 <= nx < N and 0 <= ny < N and grid[nx][ny] is None: grid[nx][ny] = 'B' bob_queue.append((nx, ny)) bob_count += 1 alice_turn = not alice_turn if alice_count > bob_count: print("Alice") else: print("Bob") N, K = map(int, input().split()) play_game(N, K)