結果
問題 | No.1557 Binary Variable |
ユーザー | Programmerryoki |
提出日時 | 2021-06-25 22:54:00 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 936 ms / 2,000 ms |
コード長 | 1,978 bytes |
コンパイル時間 | 105 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 15,708 KB |
最終ジャッジ日時 | 2024-06-25 08:47:23 |
合計ジャッジ時間 | 31,988 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 907 ms
15,708 KB |
testcase_01 | AC | 861 ms
11,136 KB |
testcase_02 | AC | 31 ms
11,136 KB |
testcase_03 | AC | 32 ms
11,008 KB |
testcase_04 | AC | 936 ms
11,136 KB |
testcase_05 | AC | 919 ms
11,136 KB |
testcase_06 | AC | 932 ms
11,136 KB |
testcase_07 | AC | 921 ms
11,136 KB |
testcase_08 | AC | 928 ms
11,136 KB |
testcase_09 | AC | 926 ms
11,136 KB |
testcase_10 | AC | 913 ms
11,136 KB |
testcase_11 | AC | 928 ms
11,136 KB |
testcase_12 | AC | 913 ms
11,136 KB |
testcase_13 | AC | 932 ms
11,136 KB |
testcase_14 | AC | 907 ms
11,136 KB |
testcase_15 | AC | 933 ms
11,136 KB |
testcase_16 | AC | 877 ms
11,136 KB |
testcase_17 | AC | 908 ms
11,136 KB |
testcase_18 | AC | 908 ms
11,136 KB |
testcase_19 | AC | 893 ms
11,136 KB |
testcase_20 | AC | 889 ms
11,136 KB |
testcase_21 | AC | 891 ms
11,264 KB |
testcase_22 | AC | 897 ms
11,136 KB |
testcase_23 | AC | 876 ms
11,136 KB |
testcase_24 | AC | 891 ms
11,136 KB |
testcase_25 | AC | 893 ms
11,264 KB |
testcase_26 | AC | 901 ms
11,264 KB |
testcase_27 | AC | 900 ms
11,264 KB |
testcase_28 | AC | 893 ms
11,136 KB |
testcase_29 | AC | 891 ms
11,264 KB |
testcase_30 | AC | 886 ms
11,264 KB |
testcase_31 | AC | 893 ms
11,136 KB |
testcase_32 | AC | 887 ms
11,136 KB |
testcase_33 | AC | 899 ms
11,136 KB |
testcase_34 | AC | 30 ms
11,008 KB |
testcase_35 | AC | 31 ms
11,008 KB |
testcase_36 | AC | 31 ms
11,008 KB |
ソースコード
from bisect import bisect_left N,M = [int(i) for i in input().split()] union = [] dic = {} for _ in range(M): # print(union) # print(dic) L,R = [int(i) for i in input().split()] ind = bisect_left(union, L) if len(union) == 0: union.append(L) dic[L] = (L,R) if ind == 0: l,r = dic[union[0]] if R < l: union = [L] + union dic[L] = (L,R) continue n = None if L <= l <= R <= r: n = (l, R) elif L <= l <= r <= R: n = (l,r) union[0] = n[0] del dic[l] dic[n[0]] = n elif ind == len(union): l,r = dic[union[ind-1]] if r < L: union.append(L) dic[L] = (L,R) continue elif l <= L <= r <= R: n = (L,r) elif l <= L <= R <= r: n = (L,R) elif L <= l <= R <= r: n = (l, R) elif L <= l <= r <= R: n = (l,r) union[ind-1] = n[0] del dic[l] dic[n[0]] = n else: l,r = dic[union[ind-1]] n = None if r < L: l,r = dic[union[ind]] if R < l: union = [L] + union dic[L] = (L,R) continue n = None if l <= L <= r <= R: n = (L,r) elif l <= L <= R <= r: n = (L,R) elif L <= l <= R <= r: n = (l, R) elif L <= l <= r <= R: n = (l,r) union[ind] = n[0] del dic[l] dic[n[0]] = n continue elif l <= L <= r <= R: n = (L,r) elif l <= L <= R <= r: n = (L,R) elif L <= l <= R <= r: n = (l, R) elif L <= l <= r <= R: n = (l,r) union[ind-1] = n[0] del dic[l] dic[n[0]] = n # print(union) # print(dic) print(N-len(union))