結果
問題 | No.2443 特殊線形群の標準表現 |
ユーザー |
![]() |
提出日時 | 2023-08-25 22:49:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 533 ms / 3,000 ms |
コード長 | 1,908 bytes |
コンパイル時間 | 2,082 ms |
コンパイル使用メモリ | 196,080 KB |
最終ジャッジ日時 | 2025-02-16 14:14:50 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#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--)ll b;ll positive_modulo(ll i, ll n) {return (i % n + n) % n;}void mult(ll m1[2][2], ll m2[2][2], ll result[2][2]){result[0][0] = positive_modulo(m1[0][0]*m2[0][0]+m1[0][1]*m2[1][0],b);result[0][1] = positive_modulo(m1[0][0]*m2[0][1]+m1[0][1]*m2[1][1],b);result[1][0] = positive_modulo(m1[1][0]*m2[0][0]+m1[1][1]*m2[1][0],b);result[1][1] = positive_modulo(m1[1][0]*m2[0][1]+m1[1][1]*m2[1][1],b);}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;}