結果

問題 No.2443 特殊線形群の標準表現
ユーザー Nikkuniku029Nikkuniku029
提出日時 2023-08-25 22:36:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 856 ms / 3,000 ms
コード長 912 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 149,184 KB
最終ジャッジ日時 2023-08-25 22:36:23
合計ジャッジ時間 7,597 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
70,924 KB
testcase_01 AC 61 ms
71,040 KB
testcase_02 AC 61 ms
71,040 KB
testcase_03 AC 63 ms
71,380 KB
testcase_04 AC 62 ms
71,088 KB
testcase_05 AC 63 ms
71,336 KB
testcase_06 AC 64 ms
71,260 KB
testcase_07 AC 72 ms
71,264 KB
testcase_08 AC 60 ms
71,000 KB
testcase_09 AC 61 ms
70,856 KB
testcase_10 AC 60 ms
71,076 KB
testcase_11 AC 59 ms
71,004 KB
testcase_12 AC 72 ms
76,284 KB
testcase_13 AC 142 ms
78,656 KB
testcase_14 AC 222 ms
85,376 KB
testcase_15 AC 700 ms
149,044 KB
testcase_16 AC 856 ms
148,936 KB
testcase_17 AC 675 ms
149,184 KB
testcase_18 AC 697 ms
148,948 KB
testcase_19 AC 692 ms
148,656 KB
testcase_20 AC 629 ms
149,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def mat_mul(a, b, MOD):
    """
    a: 行列(2次元配列)I*J
    b: 行列(2次元配列)J*K
    """
    I, J, K = len(a), len(b[0]), len(b)
    c = [[0] * J for _ in range(I)]
    for i in range(I):
        for j in range(J):
            for k in range(K):
                c[i][j] += a[i][k] * b[k][j]
            c[i][j] %= MOD
    return c


N, B, Q = map(int, input().split())
A = []
cumA = [[[1, 0], [0, 1]]]
cumA_inv = [[[1, 0], [0, 1]]]
for _ in range(N):
    An = [list(map(int, input().split())) for _ in range(2)]
    A_inv = [[An[1][1], -An[0][1]], [-An[1][0], An[0][0]]]
    cumA.append(mat_mul(An, cumA[-1], B))
    cumA_inv.append(mat_mul(cumA_inv[-1], A_inv, B))
ans = []
for _ in range(Q):
    L, R, x, y = map(int, input().split())
    C = mat_mul(cumA[R], cumA_inv[L], B)
    z = (C[0][0]*x+C[0][1]*y) % B
    w = (C[1][0]*x+C[1][1]*y) % B
    ans.append((z, w))
for c in ans:
    print(*c)
0