Submission #35694033


Source Code Expand

def main(H, W, rs, cs, N, rc, Q, dl):
    def check(r, c):
        return 1 <= r <= H and 1 <= c <= W and [r, c] not in rc

    
    ret = []
    now = rs, cs
    for d, l in dl:
        for _ in range(int(l)):
            r, c = now
            if d == "L":
                nxt = [r, c - 1]
            elif d == "R":
                nxt = [r, c + 1]
            elif d == "U":
                nxt = [r - 1, c]
            elif d == "D":
                nxt = [r + 1, c]
            
            if check(*nxt): 
                now = nxt
                continue
            break
        print(*now)


H, W, rs, cs = map(int, input().split())
N = int(input())
rc = [list(map(int, input().split())) for _ in range(N)]
Q = int(input())
dl = [input().split() for _ in range(Q)]

main(H, W, rs, cs, N, rc, Q, dl)

  

Submission Info

Submission Time
Task D - LRUD Instructions
User arakaki_tokyo
Language PyPy3 (7.3.0)
Score 0
Code Size 849 Byte
Status TLE
Exec Time 3312 ms
Memory 153960 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 2
AC × 4
TLE × 25
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 533 ms 127468 KiB
001.txt TLE 3311 ms 120488 KiB
002.txt TLE 3311 ms 120672 KiB
003.txt TLE 3312 ms 153960 KiB
004.txt TLE 3312 ms 153184 KiB
005.txt TLE 3312 ms 153796 KiB
006.txt TLE 3312 ms 152992 KiB
007.txt AC 538 ms 123520 KiB
008.txt TLE 3312 ms 153616 KiB
009.txt TLE 3310 ms 88984 KiB
010.txt TLE 3311 ms 113408 KiB
011.txt TLE 3311 ms 114804 KiB
012.txt TLE 3312 ms 138656 KiB
013.txt TLE 3312 ms 153600 KiB
014.txt TLE 3312 ms 153808 KiB
015.txt TLE 3312 ms 153880 KiB
016.txt TLE 3312 ms 153904 KiB
017.txt TLE 3312 ms 152260 KiB
018.txt TLE 3312 ms 151880 KiB
019.txt TLE 3312 ms 151640 KiB
020.txt TLE 3312 ms 151444 KiB
021.txt TLE 3312 ms 151336 KiB
022.txt TLE 3312 ms 151496 KiB
023.txt TLE 3312 ms 151532 KiB
024.txt TLE 3312 ms 151644 KiB
025.txt TLE 3312 ms 151400 KiB
026.txt TLE 3312 ms 151348 KiB
example0.txt AC 63 ms 61916 KiB
example1.txt AC 52 ms 61960 KiB