結果
問題 | No.2443 特殊線形群の標準表現 |
ユーザー | MasKoaTS |
提出日時 | 2023-08-09 23:30:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 758 ms / 3,000 ms |
コード長 | 1,523 bytes |
コンパイル時間 | 257 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 159,176 KB |
最終ジャッジ日時 | 2024-11-15 21:55:05 |
合計ジャッジ時間 | 8,883 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
86,272 KB |
testcase_01 | AC | 130 ms
86,016 KB |
testcase_02 | AC | 130 ms
86,400 KB |
testcase_03 | AC | 133 ms
86,400 KB |
testcase_04 | AC | 133 ms
86,144 KB |
testcase_05 | AC | 130 ms
86,272 KB |
testcase_06 | AC | 131 ms
86,400 KB |
testcase_07 | AC | 129 ms
86,400 KB |
testcase_08 | AC | 138 ms
86,400 KB |
testcase_09 | AC | 120 ms
86,400 KB |
testcase_10 | AC | 121 ms
86,108 KB |
testcase_11 | AC | 120 ms
86,272 KB |
testcase_12 | AC | 135 ms
88,896 KB |
testcase_13 | AC | 184 ms
90,368 KB |
testcase_14 | AC | 248 ms
96,640 KB |
testcase_15 | AC | 708 ms
157,824 KB |
testcase_16 | AC | 730 ms
158,188 KB |
testcase_17 | AC | 758 ms
157,952 KB |
testcase_18 | AC | 746 ms
158,180 KB |
testcase_19 | AC | 732 ms
157,804 KB |
testcase_20 | AC | 645 ms
159,176 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)