結果

問題 No.1742 Binary Indexed Train
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-11-12 23:25:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,068 ms / 3,000 ms
コード長 374 bytes
コンパイル時間 296 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 102,548 KB
最終ジャッジ日時 2024-05-04 11:14:04
合計ジャッジ時間 30,986 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
51,712 KB
testcase_01 AC 35 ms
51,456 KB
testcase_02 AC 36 ms
52,096 KB
testcase_03 AC 1,732 ms
92,080 KB
testcase_04 AC 1,415 ms
90,880 KB
testcase_05 AC 1,368 ms
90,880 KB
testcase_06 AC 296 ms
78,208 KB
testcase_07 AC 311 ms
77,568 KB
testcase_08 AC 2,008 ms
102,016 KB
testcase_09 AC 1,892 ms
101,920 KB
testcase_10 AC 2,040 ms
102,204 KB
testcase_11 AC 2,068 ms
102,548 KB
testcase_12 AC 2,035 ms
102,128 KB
testcase_13 AC 1,413 ms
90,752 KB
testcase_14 AC 1,287 ms
90,368 KB
testcase_15 AC 344 ms
77,952 KB
testcase_16 AC 361 ms
80,000 KB
testcase_17 AC 680 ms
79,848 KB
testcase_18 AC 735 ms
80,640 KB
testcase_19 AC 397 ms
78,592 KB
testcase_20 AC 105 ms
76,416 KB
testcase_21 AC 352 ms
78,208 KB
testcase_22 AC 810 ms
81,536 KB
testcase_23 AC 156 ms
76,800 KB
testcase_24 AC 120 ms
76,672 KB
testcase_25 AC 954 ms
87,552 KB
testcase_26 AC 430 ms
79,104 KB
testcase_27 AC 801 ms
85,848 KB
testcase_28 AC 150 ms
76,544 KB
testcase_29 AC 957 ms
83,904 KB
testcase_30 AC 600 ms
81,408 KB
testcase_31 AC 1,178 ms
89,856 KB
testcase_32 AC 449 ms
80,384 KB
testcase_33 AC 228 ms
78,300 KB
testcase_34 AC 1,036 ms
84,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(3*10**5)
def solve(s,t,l,r):
    if t <= l or r <= s:
        return 0

    elif s <= l and r <= t:
        return 1
    else:
        m =(r+l)>>1
        x = solve(s,t,l,m)
        y = solve(s,t,m,r)
        return x+y

n,q = map(int,input().split())
M = 1<<n
for i in range(q):
    s,t = map(int,input().split())
    print(solve(s,t,0,M))
0