結果
問題 |
No.3275 Minesweeper on Graph
|
ユーザー |
👑 |
提出日時 | 2024-07-31 02:57:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 1,138 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,752 KB |
最終ジャッジ日時 | 2024-07-31 02:57:45 |
合計ジャッジ時間 | 5,181 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 3 |
other | RE * 40 |
ソースコード
import pulp N, M = map(int, input().split()) A = list(map(int, input().split())) graph = [[] for _ in range(N)] for _ in range(M): x, y = map(int, input().split()) graph[x-1].append(y-1) graph[y-1].append(x-1) problem = pulp.LpProblem(sense=pulp.LpMaximize) X = [pulp.LpVariable(name=f'x_{i}', cat=pulp.LpBinary) for i in range(N)] problem += sum(X) for u in range(N): problem += sum(X[v] for v in graph[u]) == A[u] problem.solve(pulp.PULP_CBC_CMD(msg=False)) ans = [int(pulp.value(x)) for x in X] check = [0] * N for u, x in enumerate(ans): if x < 0 or 1 < x: print("No") exit() for v in graph[u]: check[v] += x if A == check: print("Yes") print(*ans) else: print("No")