結果
問題 | No.2443 特殊線形群の標準表現 |
ユーザー | MasKoaTS |
提出日時 | 2023-08-09 23:30:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 640 ms / 3,000 ms |
コード長 | 1,523 bytes |
コンパイル時間 | 215 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 159,432 KB |
最終ジャッジ日時 | 2024-04-27 17:41:38 |
合計ジャッジ時間 | 7,577 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 118 ms
86,144 KB |
testcase_01 | AC | 116 ms
86,400 KB |
testcase_02 | AC | 118 ms
86,912 KB |
testcase_03 | AC | 119 ms
86,612 KB |
testcase_04 | AC | 121 ms
86,528 KB |
testcase_05 | AC | 117 ms
86,524 KB |
testcase_06 | AC | 114 ms
86,144 KB |
testcase_07 | AC | 115 ms
86,400 KB |
testcase_08 | AC | 118 ms
86,184 KB |
testcase_09 | AC | 117 ms
86,272 KB |
testcase_10 | AC | 116 ms
86,528 KB |
testcase_11 | AC | 115 ms
86,192 KB |
testcase_12 | AC | 125 ms
89,088 KB |
testcase_13 | AC | 169 ms
90,376 KB |
testcase_14 | AC | 225 ms
97,024 KB |
testcase_15 | AC | 583 ms
158,336 KB |
testcase_16 | AC | 640 ms
158,080 KB |
testcase_17 | AC | 576 ms
158,220 KB |
testcase_18 | AC | 592 ms
158,208 KB |
testcase_19 | AC | 591 ms
158,280 KB |
testcase_20 | AC | 505 ms
159,432 KB |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp()[:-1] getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] #di = coll.defaultdict(int) """ Main Code """ n, b, q = getNs() As = [[getList() for _ in [0] * 2] for _ in [0] * n] query = [getList() for _ in [0] * q] def prod(A, B): ret = [[0, 0], [0, 0]] for i in range(2): for j in range(2): for k in range(2): ret[i][j] += A[i][k] * B[k][j] ret[i][j] %= b return ret A_prod = [[1, 0], [0, 1]] Bs = [A_prod] for A in As: A_prod = prod(A, A_prod) Bs.append(A_prod) def inverse(A): return [[A[1][1], -A[0][1]], [-A[1][0], A[0][0]]] def prod_vector(A, vec): ret = [0, 0] for i in range(2): for j in range(2): ret[i] += A[i][j] * vec[j] ret[i] %= b return ret for l, r, x, y in query: vec = [x, y] ans = prod_vector(prod(Bs[r], inverse(Bs[l])), vec) print(*ans)