結果

問題 No.1742 Binary Indexed Train
ユーザー SSRSSSRS
提出日時 2021-11-12 21:37:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 354 ms / 3,000 ms
コード長 456 bytes
コンパイル時間 1,428 ms
コンパイル使用メモリ 167,932 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-04 07:42:10
合計ジャッジ時間 10,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 261 ms
6,940 KB
testcase_04 AC 265 ms
6,944 KB
testcase_05 AC 273 ms
6,944 KB
testcase_06 AC 148 ms
6,940 KB
testcase_07 AC 151 ms
6,940 KB
testcase_08 AC 349 ms
6,944 KB
testcase_09 AC 354 ms
6,940 KB
testcase_10 AC 350 ms
6,944 KB
testcase_11 AC 342 ms
6,940 KB
testcase_12 AC 347 ms
6,940 KB
testcase_13 AC 254 ms
6,944 KB
testcase_14 AC 257 ms
6,944 KB
testcase_15 AC 69 ms
6,940 KB
testcase_16 AC 59 ms
6,944 KB
testcase_17 AC 202 ms
6,940 KB
testcase_18 AC 205 ms
6,940 KB
testcase_19 AC 104 ms
6,940 KB
testcase_20 AC 9 ms
6,940 KB
testcase_21 AC 77 ms
6,940 KB
testcase_22 AC 224 ms
6,940 KB
testcase_23 AC 17 ms
6,940 KB
testcase_24 AC 8 ms
6,944 KB
testcase_25 AC 179 ms
6,944 KB
testcase_26 AC 123 ms
6,944 KB
testcase_27 AC 178 ms
6,940 KB
testcase_28 AC 20 ms
6,944 KB
testcase_29 AC 219 ms
6,940 KB
testcase_30 AC 100 ms
6,944 KB
testcase_31 AC 252 ms
6,940 KB
testcase_32 AC 85 ms
6,944 KB
testcase_33 AC 30 ms
6,940 KB
testcase_34 AC 160 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int dfs(long long L, long long R, long long l, long long r){
  if (r <= L || R <= l){
    return 0;
  } else if (L <= l && r <= R){
    return 1;
  } else {
    long long m = (l + r) / 2;
    return dfs(L, R, l, m) + dfs(L, R, m, r);
  }
}
int main(){
  int N, Q;
  cin >> N >> Q;
  for (int i = 0; i < Q; i++){
    long long S, T;
    cin >> S >> T;
    cout << dfs(S, T, 0, (long long) 1 << N) << endl;
  }
}
0