English
Open in Telegram

Postdef solve(N, M, grid, K):

1 August 2025
D
Deloitte | COGNIZANT | IBM | CAPGEMINI
def solve(N, M, grid, K): def is_star(r, c, grid): val = grid[r][c] if val == 0: return False for dr, dc in [(-1,0), (1,0), (0,-1), (0,1)]: nr, nc = r + dr, c + dc if not (0 <= nr < N and 0 <= nc < M): return False if grid[nr][nc] != val: return False return True def check_win(grid): for r in range(1, N-1): for c in range(1, M-1): if is_star(r, c, grid): return True return False def serialize(grid): return tuple(tuple(row) for row in grid) def dfs(state, turn): grid = [list(row) for row in state] if check_win(grid): return (0, 1, 0) if turn == 1 else (0, 0, 1) moves = [(r, c) for r in range(N) for c in range(M) if grid[r][c] == 0] if not moves: return (1, 0, 0) total = [0, 0, 0] for r, c in moves: for fruit in range(1, K+1): grid[r][c] = fruit res = dfs(serialize(grid), 1 - turn) for i in range(3): total[i] += res[i] grid[r][c] = 0 # backtrack return tuple(total) result = dfs(serialize(grid), 0) print(*result) The game of grid✅✅
1.2K ·

Nearby in the feed

DDeloitte | COGNIZANT | IBM | CAPGEMINIdef ABpair(N): res=1 while True: if N+res==2*(N^res): return res res+=1 Arithmetic bitwise pairs✅ //GalaxE solutions✅DDeloitte | COGNIZANT | IBM | CAPGEMINIdef solve(N,Q,commands): slots=[0]*N for idx in commands: i=idx[0] slots[i-1]^=1 return sum(slots) Memory slot Flip✅
this message
DDeloitte | COGNIZANT | IBM | CAPGEMINIdef solve(N, K, Count, A, Q, XY): results = [] for x, y in XY: p = A[x - 1] c = 0 for i in range(N): if A[i] > p: c += Count[i] e =DDeloitte | COGNIZANT | IBM | CAPGEMINIPhoto
DDeloitte | COGNIZANT | IBM | CAPGEMINIDeloitte | COGNIZANT | IBM | CAPGEMINI@python_java_Coding · channel · Tech
7 178subscribers451average post reach
Venue feed Open in Telegram

An open public feed from the search index ChatCrawler — “Google for public Telegram”; refreshed as the venue is crawled. Times are UTC.

Public content only, official Telegram API. About · FAQ · Index limits · Remove a page · Catalog · Search · How we count