結果

問題 No.2443 特殊線形群の標準表現
ユーザー bortikbortik
提出日時 2023-08-25 22:39:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,833 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 204,592 KB
実行使用メモリ 12,684 KB
最終ジャッジ日時 2024-06-06 17:19:55
合計ジャッジ時間 6,479 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 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,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 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,944 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;

#define ll long long
#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, n, a) for (int i = (int)(n); i >= (int)(a); i--)

int b;

void mult(ll m1[2][2], ll m2[2][2], ll result[2][2]){
    result[0][0] = m1[0][0]*m2[0][0]+m1[0][1]*m2[1][0];
    result[0][1] = m1[0][0]*m2[0][1]+m1[0][1]*m2[1][1];
    result[1][0] = m1[1][0]*m2[0][0]+m1[1][1]*m2[1][0];
    result[1][1] = m1[1][0]*m2[0][1]+m1[1][1]*m2[1][1];
}

ll positive_modulo(ll i, ll n) {
        return (i % n + n) % n;
}

void solve(){
    int n,q; cin >> n >> b >> q;
    vector<ll[2][2]> A(n+1);
    vector<ll[2][2]> Ap(n+1);
    vector<ll[2][2]> Ainv(n+1);
    Ainv[0][0][0] = 1;
    Ainv[0][0][1] = 0;
    Ainv[0][1][0] = 0;
    Ainv[0][1][1] = 1;
    Ap[0][0][0] = 1;
    Ap[0][0][1] = 0;
    Ap[0][1][0] = 0;
    Ap[0][1][1] = 1;
    rep(i,1,n+1){
        cin >> A[i][0][0] >> A[i][0][1];
        cin >> A[i][1][0] >> A[i][1][1];
        mult(A[i], Ap[i-1], Ap[i]);
        Ainv[i][0][0] = Ap[i][1][1];
        Ainv[i][0][1] = -Ap[i][0][1];
        Ainv[i][1][0] = -Ap[i][1][0];
        Ainv[i][1][1] = Ap[i][0][0];
    }
    for(int i = 0; i < q; i++){
        ll L,R,x,y; cin >> L >> R >> x >> y;
        ll mat[2][2];
        mult(Ap[R], Ainv[L], mat);
        ll z = positive_modulo(mat[0][0]*x+mat[0][1]*y,b);
        ll w = positive_modulo(mat[1][0]*x+mat[1][1]*y,b);
        cout << z << " " << w << endl;
        //cout << " no "<<mat[0][0] << " " << mat[0][1] << endl;
        //cout << "prod "<<Ap[R][0][0]<<" " << Ap[R][0][1]<<endl<< Ap[R][1][0]<< " " << Ap[R][1][1]<<endl;
        //cout << "inv " <<Ainv[L][0][0]<< " " << Ainv[L][0][1]<<endl<< Ainv[L][1][0]<<" "<< Ainv[L][1][1]<<endl;
    }

}

int main(){

    int t = 1;
    //cin >> t;
    rep(i,0,t) solve();

    return 0;
}
0