結果
問題 | No.2760 not fair position game |
ユーザー |
|
提出日時 | 2024-05-17 22:12:33 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,715 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 783,696 KB |
最終ジャッジ日時 | 2024-12-20 14:05:07 |
合計ジャッジ時間 | 26,112 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 MLE * 1 |
other | AC * 2 WA * 2 TLE * 2 MLE * 7 |
ソースコード
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)