結果

問題 No.1891 Static Xor Range Composite Query
ユーザー SSRSSSRS
提出日時 2022-03-21 22:23:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 724 bytes
コンパイル時間 2,110 ms
コンパイル使用メモリ 203,140 KB
実行使用メモリ 14,340 KB
最終ジャッジ日時 2024-04-27 06:26:01
合計ジャッジ時間 10,302 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 10 ms
6,940 KB
testcase_12 AC 10 ms
6,940 KB
testcase_13 AC 10 ms
6,944 KB
testcase_14 AC 10 ms
6,940 KB
testcase_15 AC 10 ms
6,940 KB
testcase_16 AC 10 ms
6,940 KB
testcase_17 AC 10 ms
6,940 KB
testcase_18 AC 10 ms
6,940 KB
testcase_19 AC 9 ms
6,940 KB
testcase_20 AC 10 ms
6,940 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
struct linear{
  long long a, b;
  linear(){
    a = 1;
    b = 0;
  }
  linear(int a, int b): a(a), b(b){
  }
};
linear composite(linear A, linear B){
  return linear(A.a * B.a % MOD, (A.b * B.a + B.b) % MOD);
}
int value(linear A, int x){
  return (A.a * x + A.b) % MOD;
}
int main(){
  int N, Q;
  cin >> N >> Q;
  vector<linear> f(N);
  for (int i = 0; i < N; i++){
    int a, b;
    cin >> a >> b;
    f[i] = linear(a, b);
  }
  for (int i = 0; i < Q; i++){
    int l, r, p, x;
    cin >> l >> r >> p >> x;
    linear ans;
    for (int j = l; j < r; j++){
      ans = composite(ans, f[j ^ p]);
    }
    cout << value(ans, x) << endl;
  }
}
0