結果
問題 | No.1743 Permutation Code |
ユーザー | tnodino |
提出日時 | 2022-04-23 07:41:34 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,045 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 17,828 KB |
最終ジャッジ日時 | 2024-06-24 16:58:25 |
合計ジャッジ時間 | 11,432 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 34 ms
10,880 KB |
testcase_01 | AC | 34 ms
10,880 KB |
testcase_02 | AC | 35 ms
10,752 KB |
testcase_03 | AC | 74 ms
10,880 KB |
testcase_04 | AC | 38 ms
10,752 KB |
testcase_05 | AC | 32 ms
10,880 KB |
testcase_06 | AC | 549 ms
10,752 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
ソースコード
from sys import setrecursionlimit setrecursionlimit(10**6) def operator1(C): M = len(C) cnt = 0 for b in range(1,1<<16): cnt += len(bin(b)) - 2 if cnt == M: return b, M, len(bin(b)) - 2 def operator2(C, M): Run = [] cnt = 1 for i in range(1,M): if C[i] == '0': cnt += 1 else: Run.append(cnt) cnt = 1 Run.append(cnt) return Run def operator3(N): Num = [[] for _ in range(N+1)] for i in range(1,N+1): B = bin(i)[2:] cnt = 1 for b in B[1:]: if b == '0': cnt += 1 else: Num[i].append(cnt) cnt = 1 Num[i].append(cnt) return Num def operator4(Num, N): Len = [[] for _ in range(30)] for i in range(1,N+1): Len[len(Num[i])].append(i) return Len def operator5(Run, Num, N, M): G = [[] for _ in range(N+1)] for i in range(1,N+1): L = len(Num[i]) for j in range(M-L+1): if Num[i] == Run[j:j+L]: G[i].append(j) return G def dfs(x, y): global Run, Num, Len, G, ans, Flg if len(Len[x]) == y: x -= 1 while not len(Len[x]) and x: x -= 1 y = 0 if x == 0: Answer() c = Len[x][y] L = len(Num[c]) for i in G[c]: Flg2 = 0 for k in range(L): if Flg[i+k]: Flg2 = 1 break if Flg2: continue ans[c] = i for k in range(L): Flg[i+k] = 1 dfs(x, y+1) for k in range(L): Flg[i+k] = 0 def Answer(): global ans for i in range(N+1): ans[i] = [ans[i], i] ans = ans[1:] ans.sort() for i in range(N): ans[i] = ans[i][1] print(*ans) exit() C = input() N,M,B = operator1(C) Run = operator2(C, M) M = len(Run) Num = operator3(N) Len = operator4(Num, N) G = operator5(Run, Num, N, M) ans = [0] * (N+1) Flg = [0] * M dfs(20, 0)