結果
問題 | No.2929 Miracle Branch |
ユーザー | Cecil |
提出日時 | 2024-10-14 20:12:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 1,832 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 106,196 KB |
最終ジャッジ日時 | 2024-10-14 20:12:52 |
合計ジャッジ時間 | 12,133 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
51,840 KB |
testcase_01 | AC | 66 ms
68,736 KB |
testcase_02 | AC | 63 ms
68,352 KB |
testcase_03 | AC | 69 ms
69,248 KB |
testcase_04 | AC | 72 ms
69,248 KB |
testcase_05 | AC | 70 ms
69,248 KB |
testcase_06 | AC | 71 ms
69,120 KB |
testcase_07 | AC | 70 ms
69,504 KB |
testcase_08 | AC | 70 ms
69,376 KB |
testcase_09 | AC | 71 ms
69,248 KB |
testcase_10 | AC | 69 ms
69,632 KB |
testcase_11 | AC | 70 ms
69,504 KB |
testcase_12 | AC | 66 ms
68,736 KB |
testcase_13 | AC | 68 ms
69,248 KB |
testcase_14 | AC | 69 ms
69,120 KB |
testcase_15 | AC | 69 ms
69,376 KB |
testcase_16 | AC | 67 ms
69,120 KB |
testcase_17 | AC | 67 ms
69,376 KB |
testcase_18 | AC | 97 ms
80,256 KB |
testcase_19 | AC | 99 ms
80,128 KB |
testcase_20 | AC | 110 ms
80,256 KB |
testcase_21 | AC | 102 ms
80,384 KB |
testcase_22 | AC | 70 ms
69,248 KB |
testcase_23 | AC | 107 ms
80,896 KB |
testcase_24 | AC | 129 ms
85,812 KB |
testcase_25 | AC | 99 ms
80,384 KB |
testcase_26 | AC | 79 ms
74,112 KB |
testcase_27 | AC | 86 ms
76,288 KB |
testcase_28 | AC | 66 ms
68,352 KB |
testcase_29 | AC | 66 ms
68,480 KB |
testcase_30 | AC | 68 ms
68,480 KB |
testcase_31 | AC | 73 ms
68,864 KB |
testcase_32 | AC | 67 ms
68,352 KB |
testcase_33 | AC | 70 ms
69,120 KB |
testcase_34 | AC | 206 ms
105,928 KB |
testcase_35 | AC | 203 ms
106,196 KB |
testcase_36 | AC | 69 ms
69,248 KB |
testcase_37 | AC | 222 ms
106,056 KB |
testcase_38 | AC | 203 ms
106,112 KB |
testcase_39 | AC | 201 ms
106,192 KB |
testcase_40 | AC | 221 ms
105,872 KB |
testcase_41 | AC | 200 ms
105,952 KB |
testcase_42 | AC | 201 ms
105,932 KB |
testcase_43 | AC | 208 ms
105,900 KB |
testcase_44 | AC | 216 ms
105,928 KB |
testcase_45 | AC | 70 ms
68,608 KB |
ソースコード
def Eratosthenes(N):isprime = [True for _ in range(N+1)]minfactor = [-1 for _ in range(N+1)]isprime[1] = Falseminfactor[1] = 1for p in range(2, N+1):if not isprime[p]:continueminfactor[p] = pfor q in range(p*2, N+1, p):isprime[q] = Falseif minfactor[q]==-1:minfactor[q] = pprimes = list()for p in range(2,N+1):if isprime[p]:primes.append(p)return primesX = int(input())tmp_prime = list()if X!=1:primes = Eratosthenes(200000)while True:ok = Falsefor i in primes:if X%i==0:ok = TrueX //= itmp_prime.append(i)breakif not ok:break#print(tmp_prime)#print("#", len(tmp_prime), sum(tmp_prime))prime = list()cnt_2 = 0for i in tmp_prime:if i==2:if cnt_2==1:prime.append(4)cnt_2 = 0else:cnt_2 += 1else:if cnt_2==1:prime.append(2)cnt_2 = 0prime.append(i)if cnt_2==1:prime.append(2)if X!=1:prime.append(X)#print(prime)#print("#", len(prime), sum(prime))else:prime = [1]if len(prime)+sum(prime)>2*10**5:print(-1)exit()N = len(prime)+sum(prime)G = [ [] for _ in range(N+1)]idx = len(prime)for i in range(1, len(prime)+1):for j in range(prime[i-1]):idx += 1G[i].append(idx)print(N)for i in range(1, len(prime)):G[i].append(i+1)for i in range(1, N+1):for j in G[i]:print(i,j)col = list()for i in range(len(prime)):col.append("b")for i in range(sum(prime)):col.append("g")print(*col)