結果

問題 No.2443 特殊線形群の標準表現
ユーザー shobonvipshobonvip
提出日時 2023-08-26 01:35:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 484 ms / 3,000 ms
コード長 1,922 bytes
コンパイル時間 4,411 ms
コンパイル使用メモリ 265,380 KB
実行使用メモリ 8,940 KB
最終ジャッジ日時 2023-08-26 01:35:24
合計ジャッジ時間 9,583 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 47 ms
4,380 KB
testcase_15 AC 476 ms
8,760 KB
testcase_16 AC 472 ms
8,764 KB
testcase_17 AC 453 ms
8,888 KB
testcase_18 AC 484 ms
8,808 KB
testcase_19 AC 474 ms
8,820 KB
testcase_20 AC 403 ms
8,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}

template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

struct mat{
	mint v[2][2];
};

mat e(){
	mat ret;
	rep(i,0,2) rep(j,0,2){
		if (i==j) ret.v[i][j] = 1;
		else ret.v[i][j] = 0;
	}
	return ret;
}

mat te(){
	mat ret;
	rep(i,0,2) rep(j,0,2) ret.v[i][j] = 0;	
	return ret;
}

mat op(mat a, mat b){
	mat ret = te();
	rep(i,0,2){
		rep(j,0,2){
			rep(k,0,2){
				ret.v[i][j] += b.v[i][k] * a.v[k][j];
			}
		}
	}
	return ret;
}


int main(){
	int n; cin >> n;
	int b; cin >> b;
	mint::set_mod(b);
	int q; cin >> q;
	vector<mat> t(n);
	rep(i,0,n){
		rep(j,0,2){
			rep(k,0,2){
				int x; cin >> x;
				t[i].v[j][k] = x;
			}
		}
	}
	segtree<mat,op,e> seg(t);
	rep(num,0,q){
		int l, r; cin >> l >> r;
		int xx, yx; cin >> xx >> yx;
		vector<mint> z = {xx, yx};
		mat g = seg.prod(l, r);
		vector<mint> h = {
			g.v[0][0] * z[0] + g.v[0][1] * z[1],
			g.v[1][0] * z[0] + g.v[1][1] * z[1]
		};
		cout << h[0].val() << ' ' << h[1].val() << '\n';
	}
}

0