Submission #19684920


Source Code Expand

Copy
# included from snippets/main.py
def debug(*x, msg=""):
import sys
print(msg, *x, file=sys.stderr)
def solve(SOLVE_PARAMS):
pass
def gen_dot():
for i in range(9):
x, y = divmod(i, 3)
print(
f"a[{x * 3}] * b[{y}] + a[{x * 3 + 1}] * b[{y + 3}]+ a[{x * 3 + 2}] * b[{y + 6}],")
def dot(a, b):
return [
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# included from snippets/main.py


def debug(*x, msg=""):
    import sys
    print(msg, *x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def gen_dot():
    for i in range(9):
        x, y = divmod(i, 3)
        print(
            f"a[{x * 3}] * b[{y}] + a[{x * 3 + 1}] * b[{y + 3}]+ a[{x * 3 + 2}] * b[{y + 6}],")


def dot(a, b):
    return [
        a[0] * b[0] + a[1] * b[3] + a[2] * b[6],
        a[0] * b[1] + a[1] * b[4] + a[2] * b[7],
        a[0] * b[2] + a[1] * b[5] + a[2] * b[8],
        a[3] * b[0] + a[4] * b[3] + a[5] * b[6],
        a[3] * b[1] + a[4] * b[4] + a[5] * b[7],
        a[3] * b[2] + a[4] * b[5] + a[5] * b[8],
        a[6] * b[0] + a[7] * b[3] + a[8] * b[6],
        a[6] * b[1] + a[7] * b[4] + a[8] * b[7],
        a[6]*b[2] + a[7]*b[5] + a[8]*b[8]
    ]


def main():
    N = int(input())
    XY = []
    for _i in range(N):
        XY.append(tuple(map(int, input().split())))
    M = int(input())

    timeline = []
    for i in range(M):
        timeline.append(((i + 1) * 2, tuple(map(int, input().split()))))

    Q = int(input())
    QS = []
    for i in range(Q):
        q = tuple(map(int, input().split()))
        QS.append(q)
        timeline.append((q[0] * 2 + 1, q))
    timeline.sort()

    answer = {}
    trans = [1, 0, 0, 0, 1, 0, 0, 0, 1]

    OP1 = [
        0, -1, 0,
        1, 0, 0,
        0, 0, 1]
    OP2 = [
        0, 1, 0,
        -1, 0, 0,
        0, 0, 1]
    OP3 = [
        -1, 0, 0,
        0, 1, 0,
        0, 0, 1]
    OP4 = [
        1, 0, 0,
        0, -1, 0,
        0, 0, 1]

    for t, x in timeline:
        if t % 2:
            # query
            q = x
            i = q[1] - 1
            x, y = XY[i]
            newXY = dot([x, y, 1, 0, 0, 0, 0, 0, 0], trans)
            answer[q] = (newXY[0], newXY[1])

            # debug(q, answer[q], msg=":q, answer[q]")
        else:
            # ops
            if x[0] == 1:
                trans = dot(trans, OP1)
            elif x[0] == 2:
                trans = dot(trans, OP2)
            elif x[0] == 3:
                P = x[1]
                OP3[6] = 2 * P
                trans = dot(trans, OP3)
            elif x[0] == 4:
                P = x[1]
                OP4[7] = 2 * P
                trans = dot(trans, OP4)

    for q in QS:
        x, y = answer[q]
        print(x, y)


T1 = """
1
1 2
4
1
3 3
2
4 2
5
0 1
1 1
2 1
3 1
4 1
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1 2
2 -1
4 -1
1 4
1 0
"""

T2 = """
2
1000000000 0
0 1000000000
4
3 -1000000000
4 -1000000000
3 1000000000
4 1000000000
2
4 1
4 2
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
5000000000 4000000000
4000000000 5000000000
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            print(k)
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


if __name__ == "__main__":
    import sys
    input = sys.stdin.buffer.readline
    read = sys.stdin.buffer.read
    sys.setrecursionlimit(10 ** 6)
    if sys.argv[-1] == "-t":
        print("testing")
        _test()
        sys.exit()
    main()
    sys.exit()

# end of snippets/main.py

Submission Info

Submission Time
Task E - Rotate and Flip
User nishiohirokazu
Language PyPy3 (7.3.0)
Score 500
Code Size 3567 Byte
Status AC
Exec Time 1509 ms
Memory 191684 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All max_01.txt, max_02.txt, max_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
max_01.txt AC 901 ms 191408 KB
max_02.txt AC 803 ms 187556 KB
max_03.txt AC 237 ms 104080 KB
random_01.txt AC 54 ms 64096 KB
random_02.txt AC 54 ms 63868 KB
random_03.txt AC 56 ms 64044 KB
random_04.txt AC 56 ms 64388 KB
random_05.txt AC 53 ms 64084 KB
random_06.txt AC 54 ms 63748 KB
random_07.txt AC 55 ms 64492 KB
random_08.txt AC 53 ms 63892 KB
random_09.txt AC 55 ms 63940 KB
random_10.txt AC 56 ms 64064 KB
random_11.txt AC 57 ms 64084 KB
random_12.txt AC 56 ms 63968 KB
random_13.txt AC 48 ms 63988 KB
random_14.txt AC 53 ms 64016 KB
random_15.txt AC 54 ms 64332 KB
random_16.txt AC 56 ms 63988 KB
random_17.txt AC 54 ms 63748 KB
random_18.txt AC 56 ms 64044 KB
random_19.txt AC 54 ms 63976 KB
random_20.txt AC 60 ms 64416 KB
random_21.txt AC 759 ms 134356 KB
random_22.txt AC 1501 ms 191388 KB
random_23.txt AC 1509 ms 191684 KB
sample_01.txt AC 71 ms 62844 KB
sample_02.txt AC 51 ms 62900 KB


2025-04-14 (Mon)
18:28:43 +00:00