結果
問題 | No.1711 Divide LCM |
ユーザー | tamato |
提出日時 | 2021-10-15 22:57:10 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,028 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 82,336 KB |
実行使用メモリ | 152,192 KB |
最終ジャッジ日時 | 2024-09-17 18:02:21 |
合計ジャッジ時間 | 14,740 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
54,144 KB |
testcase_01 | AC | 42 ms
54,528 KB |
testcase_02 | AC | 46 ms
54,528 KB |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | RE | - |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | RE | - |
testcase_10 | RE | - |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | AC | 51 ms
62,976 KB |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | AC | 65 ms
73,600 KB |
testcase_30 | RE | - |
testcase_31 | AC | 71 ms
72,064 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | AC | 62 ms
72,448 KB |
testcase_41 | AC | 58 ms
71,068 KB |
testcase_42 | AC | 62 ms
71,552 KB |
testcase_43 | AC | 56 ms
71,424 KB |
testcase_44 | AC | 56 ms
72,192 KB |
ソースコード
mod = 998244353 eps = 10**-9 def main(): import sys from itertools import combinations from random import shuffle input = sys.stdin.readline N = int(input()) A = [] PE = [] P = {} for i in range(N): M = int(input()) a = 1 D = {} for j in range(M): p, e = map(int, input().split()) if p not in P: P[p] = 0 P[p] = max(P[p], e) a *= p ** e D[p] = e A.append(a) PE.append(D) B = [] BA = [] BB = [] B_val = [] for i in range(N): D = PE[i] b = set() val = 1 for p in D: if D[p] == P[p]: b.add(p) val *= p if b: B.append(b) BA.append(A[i]) B_val.append(val) else: BB.append(A[i]) for i, b in enumerate(B): ok = 0 for pp in P: if pp not in b: # ans[j].append(BA[i]) ok = 1 break if not ok: print(-1) exit() L = len(P) P_list = list(P.keys()) shuffle(P_list) assert len(P_list) < 10 for k in range(2, L+1): for J in combinations(P_list, k): J = list(J) q = 1 for pp in J: q *= pp ans = [[] for _ in range(k)] flg = 1 for i, b in enumerate(B_val): if b % q == 0: flg = 0 break if flg: for i, b in enumerate(B): for j, pp in enumerate(J): if pp not in b: ans[j].append(BA[i]) break ans[0].extend(BB) print(k) for a in ans: a = [len(a)] + a print(*a) exit() if __name__ == '__main__': main()