Submission #22247933


Source Code Expand

from collections import deque
s = input()
n = len(s)
t = deque()
head = 1
for i in range(n):
    if s[i] == 'R':
        head *= -1
    else:
        if head == 1:
            if len(t) > 0 and t[len(t)-1] == s[i]:
                t.pop()
            else:
                t.append(s[i])
        else:
            if len(t) > 0 and t[0] == s[i]:
                t.popleft()
            else:
                t.appendleft(s[i])

if head == -1:
    t.reverse()
ret = ''
for v in t:
    ret += v
print(ret)

Submission Info

Submission Time
Task D - Message from Aliens
User Arcamon
Language Python (3.8.2)
Score 300
Code Size 528 Byte
Status AC
Exec Time 313 ms
Memory 14028 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt
All 01_sample.txt, 02_sample.txt, 03_random.txt, 04_random.txt, 05_random.txt, 06_random.txt, 07_random.txt, 08_random.txt, 09_random.txt, 10_random.txt, 11_random.txt, 12_random.txt, 13_random.txt, 14_random.txt, 15_random.txt, 16_random.txt, 17_random.txt, 18_random.txt, 19_random.txt, 20_random.txt, 21_random.txt, 22_random.txt, 23_max.txt, 24_max.txt, 25_max.txt, 26_max.txt, 27_max.txt, 28_max.txt
Case Name Status Exec Time Memory
01_sample.txt AC 29 ms 9200 KiB
02_sample.txt AC 23 ms 9188 KiB
03_random.txt AC 22 ms 9188 KiB
04_random.txt AC 21 ms 9320 KiB
05_random.txt AC 27 ms 9128 KiB
06_random.txt AC 122 ms 10556 KiB
07_random.txt AC 56 ms 9568 KiB
08_random.txt AC 22 ms 9088 KiB
09_random.txt AC 87 ms 9724 KiB
10_random.txt AC 62 ms 9864 KiB
11_random.txt AC 21 ms 9320 KiB
12_random.txt AC 24 ms 9088 KiB
13_random.txt AC 32 ms 9260 KiB
14_random.txt AC 24 ms 9196 KiB
15_random.txt AC 40 ms 9340 KiB
16_random.txt AC 29 ms 9088 KiB
17_random.txt AC 25 ms 9248 KiB
18_random.txt AC 32 ms 9288 KiB
19_random.txt AC 22 ms 9200 KiB
20_random.txt AC 32 ms 9268 KiB
21_random.txt AC 36 ms 9464 KiB
22_random.txt AC 26 ms 9096 KiB
23_max.txt AC 98 ms 10028 KiB
24_max.txt AC 180 ms 10016 KiB
25_max.txt AC 313 ms 14028 KiB
26_max.txt AC 125 ms 10012 KiB
27_max.txt AC 205 ms 11768 KiB
28_max.txt AC 212 ms 11124 KiB