結果
問題 | No.1711 Divide LCM |
ユーザー | tamato |
提出日時 | 2021-10-15 23:49:30 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,409 bytes |
コンパイル時間 | 232 ms |
コンパイル使用メモリ | 82,548 KB |
実行使用メモリ | 193,872 KB |
最終ジャッジ日時 | 2024-09-17 18:54:11 |
合計ジャッジ時間 | 15,600 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
61,284 KB |
testcase_01 | AC | 45 ms
54,740 KB |
testcase_02 | AC | 45 ms
55,428 KB |
testcase_03 | AC | 59 ms
67,244 KB |
testcase_04 | AC | 99 ms
78,896 KB |
testcase_05 | AC | 114 ms
81,660 KB |
testcase_06 | AC | 100 ms
78,748 KB |
testcase_07 | AC | 110 ms
81,088 KB |
testcase_08 | AC | 96 ms
79,008 KB |
testcase_09 | AC | 142 ms
86,204 KB |
testcase_10 | AC | 105 ms
79,068 KB |
testcase_11 | AC | 168 ms
90,560 KB |
testcase_12 | AC | 104 ms
78,760 KB |
testcase_13 | AC | 48 ms
58,528 KB |
testcase_14 | AC | 84 ms
77,712 KB |
testcase_15 | AC | 93 ms
78,564 KB |
testcase_16 | AC | 48 ms
58,548 KB |
testcase_17 | AC | 84 ms
78,028 KB |
testcase_18 | AC | 306 ms
130,424 KB |
testcase_19 | AC | 318 ms
134,296 KB |
testcase_20 | AC | 321 ms
134,276 KB |
testcase_21 | AC | 391 ms
193,872 KB |
testcase_22 | AC | 223 ms
108,012 KB |
testcase_23 | AC | 234 ms
111,116 KB |
testcase_24 | AC | 919 ms
137,040 KB |
testcase_25 | AC | 896 ms
135,340 KB |
testcase_26 | AC | 486 ms
137,080 KB |
testcase_27 | AC | 296 ms
144,200 KB |
testcase_28 | AC | 290 ms
142,404 KB |
testcase_29 | AC | 65 ms
70,368 KB |
testcase_30 | TLE | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
ソースコード
mod = 998244353 eps = 10**-9 def main(): import sys from itertools import combinations import random 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 len(b) > 0: 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()) cov = [0] * (L+1) seen = set() for b, val in zip(B, B_val): if val not in seen: seen.add(val) cov[len(b)] += 1 B_val = list(set(B_val)) B_val.sort(reverse=True) B_val_set = set(B_val) comb = L random.shuffle(P_list) for k in range(2, L+1): comb *= (L - k + 1) comb //= k if cov[k] == comb: continue for J in combinations(P_list, k): J = list(J) q = 1 for pp in J: q *= pp if q in B_val_set: continue 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()