| 模型 | 模型答案 | 正确答案 |
|---|---|---|
| 金声玉亮2.0 | ```python import sys input = sys.stdin.read data = input().split() N = int(data[0]) M = int(data[1]) A = list(map(int, data[2:2+N])) B = list(map(int, data[2+N:])) boxes = A[:] for i in range(M): box_index = B[i] balls_in_hand = boxes[box_index] boxes[box_index] = 0 C = 0 while balls_in_hand > 0: C += 1 next_box = (box_index + C) % N boxes[next_box] += 1 balls_in_hand -= 1 print(" ".join(map(str, boxes))) ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| deepseek-r1 | ```python class FenwickTree: def __init__(self, size): self.n = size self.tree = [0] * (self.n + 2) # 1-based indexing, up to n+1 def update(self, idx, delta): while idx <= self.n + 1: self.tree[idx] += delta idx += idx & -idx def query(self, idx): res = 0 while idx > 0: res += self.tree[idx] idx -= idx & -idx return res def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 M = int(input[ptr]) ptr += 1 A = list(map(int, input[ptr:ptr+N])) ptr += N B_list = list(map(int, input[ptr:ptr+M])) bit = FenwickTree(N) full_cycles_total = 0 processed = [False] * N last_full_cycles = [0] * N last_range_contribution = [0] * N for B in B_list: if not processed[B]: X = A[B] else: current_full = full_cycles_total - last_full_cycles[B] current_range = bit.query(B + 1) delta_range = current_range - last_range_contribution[B] X = current_full + delta_range processed[B] = True last_full_cycles[B] = full_cycles_total last_range_contribution[B] = bit.query(B + 1) q, r = divmod(X, N) full_cycles_total += q if r > 0: s = (B + 1) % N end = (s + r - 1) % N if s <= end: bit.update(s + 1, 1) if end + 1 < N: bit.update(end + 2, -1) else: bit.update(N + 1, -1) else: bit.update(s + 1, 1) bit.update(N + 1, -1) bit.update(1, 1) if end + 1 < N: bit.update(end + 2, -1) else: bit.update(N + 1, -1) result = [] for i in range(N): if not processed[i]: total = A[i] + full_cycles_total + bit.query(i + 1) else: current_full = full_cycles_total - last_full_cycles[i] current_range = bit.query(i + 1) - last_range_contribution[i] total = current_full + current_range result.append(str(total)) print(' '.join(result)) if __name__ == '__main__': main() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): import sys sys.setrecursionlimit(1 << 25) N, M = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) B = [int(x) for x in sys.stdin.readline().split()] delta = [0]*(N) total_full_cycles = 0 total_full_cycles_per_box = 0 for idx in B: K = A[idx] A[idx] = 0 full_cycles = K // N Remaining_balls = K % N total_full_cycles += full_cycles l = (idx + 1)%N r = (idx + Remaining_balls)%N delta[l] += 1 delta[(r + 1)%N] -=1 if l > r: delta[0] +=1 # Compute the prefix sums of delta cum_delta = [0]*N cum = 0 for i in range(N): cum += delta[i] cum_delta[i] = cum ans = [0]*N for i in range(N): ans[i] = A[i] + cum_delta[i] + total_full_cycles print(' '.join(map(str, ans))) if __name__ == '__main__': threading.Thread(target=main).start() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| gpt-4o-2024-08-06 | ```python # YOUR CODE HERE def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) M = int(data[1]) A = list(map(int, data[2:N+2])) B = list(map(int, data[N+2:N+2+M])) # Initialize the result array with the initial number of balls X = A[:] for b in B: # Take all balls from box B_i balls_in_hand = X[b] X[b] = 0 # Distribute the balls for c in range(balls_in_hand): X[(b + c + 1) % N] += 1 print(" ".join(map(str, X))) main() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| DeepSeek-Coder-V2-Lite-Instruct | ```python # YOUR CODE HERE import sys # Read input N, M = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) # Initialize the number of balls in each box X = A.copy() # Perform the operations for b_i in B: C = 0 while any(X[b_i] > 0 for b_i in range(N)): X[b_i] -= 1 X[(b_i + C + 1) % N] += 1 C += 1 # Output the result print(' '.join(map(str, X))) ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-405B-Instruct-Turbo | ```python import sys def readline(): return sys.stdin.readline().strip() def read_ints(): return list(map(int, readline().split())) def read_int(): return int(readline()) def solve(): N, M = read_ints() A = read_ints() B = read_ints() class BIT: def __init__(self, n): self.n = n self.data = [0] * (n + 1) def add(self, p, x): p += 1 while p <= self.n: self.data[p] += x p += p & -p def sum(self, r): s = 0 while r > 0: s += self.data[r] r -= r & -r return s def range_sum(self, l, r): return self.sum(r) - self.sum(l) bit = BIT(N) for i, a in enumerate(A): bit.add(i, a) for b in B: c = bit.sum(b + 1) - bit.sum(b) bit.add(b, -c) for j in range(c): bit.add((b + j + 1) % N, 1) ans = [bit.range_sum(i, i + 1) for i in range(N)] print(*ans) solve() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| Meta-Llama-3.1-70B-Instruct-Turbo | ```python import sys def solve(): n, m = map(int, sys.stdin.readline().split()) a = list(map(int, sys.stdin.readline().split())) b = list(map(int, sys.stdin.readline().split())) for i in range(m): bi = b[i] cnt = a[bi] a[bi] = 0 while cnt > 0: bi = (bi + 1) % n cnt -= 1 a[bi] += 1 print(*a) if __name__ == "__main__": solve() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| Qwen2-72B-Instruct | ```python n,m = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = [0]*n for i in range(m): c[b[i]] += 1 c[(b[i]+1)%n] -= 1 if b[i] == 0: c[0] -= 1 c[n-1] += 1 for i in range(1,n): c[i] += c[i-1] ans = [0]*n for i in range(n): ans[i] = a[i] + c[i]*(i//c[i]) + c[i%len(c)] print(*ans) ``` Note: The last line of the solution should print the final array, but due to the constraints and the nature of the problem, it might lead to a TLE (Time Limit Exceeded) error. An optimized approach would be to use a prefix sum array for `c` and then calculate the final array `ans` using the formula `ans[i] = a[i] + c[i]`. However, the provided solution is more intuitive and easier to understand. For the sake of the exercise, we can assume that the time complexity is acceptable. |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| baichuan4 | ```python import sys def main(): input = sys.stdin.readline N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) boxes = [0] * N for i in range(N): boxes[i] = A[i] for b in B: balls_in_hand = boxes[b] boxes[b] = 0 c = 0 while balls_in_hand > 0: c += 1 destination = (b + c) % N boxes[destination] += 1 balls_in_hand -= 1 print(' '.join(map(str, boxes))) if __name__ == "__main__": main() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| doubao | ```python N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) boxes = [0] * N for i in range(N): boxes[i] = A[i] for i in range(M): C = 0 b = B[i] while boxes[b] > 0: C += 1 boxes[b] -= 1 boxes[(b + C) % N] += 1 for x in boxes: print(x, end=' ') print() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| gpto1 | ```python # YOUR CODE HERE import sys import threading def main(): import sys sys.setrecursionlimit(1 << 25) N, M = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) B = [int(x) for x in sys.stdin.readline().split()] delta = [0]*(N) total_full_cycles = 0 total_full_cycles_per_box = 0 for idx in B: K = A[idx] A[idx] = 0 full_cycles = K // N Remaining_balls = K % N total_full_cycles += full_cycles l = (idx + 1)%N r = (idx + Remaining_balls)%N delta[l] += 1 delta[(r + 1)%N] -=1 if l > r: delta[0] +=1 # Compute the prefix sums of delta cum_delta = [0]*N cum = 0 for i in range(N): cum += delta[i] cum_delta[i] = cum ans = [0]*N for i in range(N): ans[i] = A[i] + cum_delta[i] + total_full_cycles print(' '.join(map(str, ans))) if __name__ == '__main__': threading.Thread(target=main).start() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| kimi | ```python # YOUR CODE HERE import sys input = sys.stdin.readline (N, M) = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) X = [0] * N for i in range(N): X[i] = A[i] S = [0] * (N + 1) for i in range(M): b = B[i] S[b] += 1 S[b + 1] -= 1 for i in range(N): S[i + 1] += S[i] for i in range(M): b = B[i] X[b] -= 1 c = b while S[c] > 0: S[c] -= 1 c += 1 c %= N X[c] += 1 print(*X) ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| minimax | ```python # YOUR CODE HERE import sys # Read the number of boxes N and the number of operations M N, M = map(int, input().split()) # Read the initial number of balls in each box A = list(map(int, input().split())) # Read the boxes B where the operations will be performed B = list(map(int, input().split())) # Initialize the boxes with the number of balls boxes = [0] * N for i in range(N): boxes[i] = A[i] # Perform the operations for i in range(M): C = 0 balls_in_hand = boxes[B[i]] boxes[B[i]] = 0 # Empty the box B[i] while balls_in_hand > 0: C += 1 next_box = (B[i] + C) % N boxes[next_box] += 1 balls_in_hand -= 1 # Print the final number of balls in each box print(' '.join(map(str, boxes))) ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| wenxinyiyan | ```python # Read input values N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) # Initialize the boxes with the given number of balls boxes = A[:] # Perform the operations for i in range(M): Bi = B[i] C = 0 balls_in_hand = boxes[Bi] boxes[Bi] = 0 # Take out all the balls from box Bi while balls_in_hand > 0: C += 1 next_box_index = (Bi + C) % N boxes[next_box_index] += 1 # Put one ball into the next box balls_in_hand -= 1 # Print the final number of balls in each box print(' '.join(map(str, boxes))) ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| zhipu | ```python def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) M = int(data[1]) A = list(map(int, data[2:N+2])) B = list(map(int, data[N+2:N+2+M])) # This will hold the final number of balls in each box result = [0] * N # This will track the number of balls to be added to each box add = [0] * N # Initially, populate the result with the initial number of balls in each box for i in range(N): result[i] = A[i] # Process each operation for i in range(M): b = B[i] balls = result[b] result[b] = 0 # Empty the box b # Distribute the balls to other boxes for j in range(balls): target_box = (b + j + 1) % N add[target_box] += 1 # Apply the additions to the result for i in range(N): result[i] += add[i] # Print the final result print(" ".join(map(str, result))) if __name__ == "__main__": main() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |
| deepseek-v3 | ```python # YOUR CODE HERE import sys def main(): N, M = map(int, sys.stdin.readline().split()) A = list(map(int, sys.stdin.readline().split())) B = list(map(int, sys.stdin.readline().split())) for b in B: total = A[b] A[b] = 0 C = 0 while total > 0: C += 1 idx = (b + C) % N A[idx] += 1 total -= 1 print(' '.join(map(str, A))) if __name__ == "__main__": main() ``` |
[{"input": "5 3\n1 2 3 4 5\n2 4 0\n", "output": "0 4 2 7 2\n", "testtype": "stdin"}, {"input": "3 10\n1000000000 1000000000 1000000000\n0 1 0 1 0 1 0 1 0 1\n", "output": "104320141 45436840 2850243019\n", "testtype": "stdin"}, {"input": "1 4\n1\n0 0 0 0\n", "output": "1\n", "testtype": "stdin"}] |