結果

問題 No.2443 特殊線形群の標準表現
ユーザー twooimptwooimp
提出日時 2023-08-25 23:19:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,124 bytes
コンパイル時間 1,813 ms
コンパイル使用メモリ 174,740 KB
実行使用メモリ 32,700 KB
最終ジャッジ日時 2023-08-25 23:19:20
合計ジャッジ時間 6,752 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,384 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

vector<vector<ll>> mul(vector<vector<ll>> v1,vector<vector<ll>> v2,ll mod){
  ll s=v1.size();
  vector<vector<ll>> res(s,vector<ll>(s,0));
  for(ll i=0;i<s;i++){
    for(ll j=0;j<s;j++){
      for(ll k=0;k<s;k++){
        res[i][j]+=v1[i][k]*v2[k][j];
        res[i][j]+=mod;
        res[i][j]%=mod;
      }
    }
  }
  return res;
}

int main(){
  ll n,b,q;
  cin>>n>>b>>q;
  vector<vector<vector<ll>>> a(n,vector<vector<ll>>(2,vector<ll>(2)));
  for(ll i=0;i<n;i++){
    for(ll j=0;j<2;j++){
      for(ll k=0;k<2;k++){
        cin>>a[i][j][k];
      }
    }
  }
  vector<vector<vector<ll>>> sum(n,vector<vector<ll>>(2,vector<ll>(2)));
  sum[0][0][0]=a[0][0][0];
  sum[0][0][1]=a[0][0][1];
  sum[0][1][0]=a[0][1][0];
  sum[0][1][1]=a[0][1][1];
  for(ll i=1;i<n;i++){
    sum[i]=mul(a[i],sum[i-1],b);
  }
  while(q--){
    ll l,r,x,y;
    cin>>l>>r>>x>>y;
    cout<<(sum[max((ll)0,min(n-1,r-l))][0][0]%b*x+sum[max((ll)0,min(n-1,r-l))][0][1]*y%b)%b<<" ";
    cout<<(sum[max((ll)0,min(n-1,r-l))][1][0]%b*x+sum[max((ll)0,min(n-1,r-l))][1][1]*y%b)%b<<endl;
  }
}
0