結果
問題 | No.556 仁義なきサルたち |
ユーザー | dragonlaunch |
提出日時 | 2017-11-12 05:39:09 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,399 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 10,856 KB |
実行使用メモリ | 14,164 KB |
最終ジャッジ日時 | 2023-08-16 09:15:21 |
合計ジャッジ時間 | 7,575 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
12,500 KB |
testcase_01 | AC | 17 ms
7,976 KB |
testcase_02 | AC | 17 ms
8,112 KB |
testcase_03 | AC | 17 ms
7,956 KB |
testcase_04 | AC | 16 ms
7,964 KB |
testcase_05 | AC | 18 ms
8,108 KB |
testcase_06 | AC | 20 ms
7,964 KB |
testcase_07 | AC | 23 ms
8,032 KB |
testcase_08 | AC | 24 ms
7,972 KB |
testcase_09 | AC | 67 ms
8,432 KB |
testcase_10 | AC | 118 ms
8,524 KB |
testcase_11 | AC | 170 ms
8,376 KB |
testcase_12 | AC | 156 ms
8,432 KB |
testcase_13 | AC | 269 ms
9,016 KB |
testcase_14 | TLE | - |
testcase_15 | TLE | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import time dellist = lambda items, indexes: [item for index, item in enumerate(items) if index not in indexes] N,M = [int(i) for i in input().split()] battle = [] for i in range (M): battle.append(list(int(i) for i in input().split())) monkey = list(range(1,N+1)) monk = monkey.copy() group = [] for i in range(N): group.append([(monkey[i])]) #print(group,battle) def bat(a,b): if a == b: return a elif len(a) == len(b): if a[0] < b[0]: for i in b: monk[i-1] = a[0] return a + b if b[0] < a[0]: for i in a: monk[i-1] = b[0] return b + a elif len(a) > len(b): for i in b: monk[i-1] = a[0] return a + b elif len(b) > len(a): for i in a: monk[i-1] = b[0] return b + a for i in range(M): count = 0 k = m = 0 for j in range(len(group)): if battle[i][0] in group[j]: x = group[j] k = j count +=1 if battle[i][1] in group[j]: y = group[j] m = j count+=1 if count == 2: break if k != m: group.pop(k) if k > m: group.pop(m) if k < m: group.pop(m-1) if x == y: group.pop(k) group.append(bat(x,y)) for i in range(N): print(monk[i])