problem_id stringlengths 6 6 | user_id stringlengths 10 10 | time_limit float64 1k 8k | memory_limit float64 262k 1.05M | problem_description stringlengths 48 1.55k | codes stringlengths 35 98.9k | status stringlengths 28 1.7k | submission_ids stringlengths 28 1.41k | memories stringlengths 13 808 | cpu_times stringlengths 11 610 | code_sizes stringlengths 7 505 |
|---|---|---|---|---|---|---|---|---|---|---|
p02756 | u160169132 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['#158_D\ns = input()\nq = int(input())\n\nfrom collections import deque\n\ns = deque(s)\n\nrev = 1\nfor _ in range(q):\n Q = list(input().split())\n if Q[0] == "1":\n rev *= -1\n elif Q[0] == "2":\n if (Q[1]=="1" and rev==1) or (Q[1]=="2" and rev==-1):\n s.append(Q[2])\n elif (Q[1]=="2" and rev==1) or (Q[1]=="1" and rev==-1):\n s.appendleft(Q[2])\n \ns = "".join(s)\n \nif rev == -1:\n s = s[::-1]\n\nprint(s)', '#158_D\ns = input()\nq = int(input())\n\nfrom collections import deque\n\ns = deque(s)\n\nrev = 1\nfor _ in range(q):\n Q = list(input().split())\n if Q[0] == "1":\n rev *= -1\n elif Q[0] == "2":\n if (Q[1]=="1" and rev==1) or (Q[1]=="2" and rev==-1):\n s.append(Q[2])\n elif (Q[1]=="2" and rev==1) or (Q[1]=="1" and rev==-1):\n s.appendleft(Q[2])\n \ns = "".join(list(s))\n \nif rev == -1:\n s = s[::-1]\n\nprint(s)', '#158_D\ns = input()\nq = int(input())\n\nfrom collections import deque\n\ns = deque(s)\n\nrev = 1\nfor _ in range(q):\n Q = list(input().split())\n if Q[0] == "1":\n rev *= -1\n elif Q[0] == "2":\n if (Q[1]=="1" and rev==1) or (Q[1]=="2" and rev==-1):\n s.appendleft(Q[2])\n elif (Q[1]=="2" and rev==1) or (Q[1]=="1" and rev==-1):\n s.append(Q[2])\n \ns = "".join(s)\n \nif rev == -1:\n s = s[::-1]\n\nprint(s)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s517600751', 's530486594', 's034246711'] | [14308.0, 14156.0, 14012.0] | [344.0, 340.0, 334.0] | [463, 469, 463] |
p02756 | u164029270 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['B = input()\norder = True\nF = ""\nfor q in range(int(input())):\n T = input().rstrip().split()\n if T[0] == "1":\n order ^= True\n else:\n f,c = T[1],T[2]\n if not((f == "1") ^ order):\n F += c\n else:\n B += c\n print(F,B)\nF = F[::-1]+B\nif not order:\n F = F[::-1]\nprint(F)', 'B = input()\norder = True\nF = ""\nfor q in range(int(input())):\n T = input().rstrip().split()\n if T[0] == "1":\n order ^= True\n else:\n f,c = T[1],T[2]\n if not((f == "1") ^ order):\n F += c\n else:\n B += c\n \nF = F[::-1]+B\nif not order:\n F = F[::-1]\nprint(F)'] | ['Runtime Error', 'Accepted'] | ['s629800066', 's919040342'] | [134532.0, 4304.0] | [182.0, 487.0] | [326, 327] |
p02756 | u166621202 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import collections\nN = int(input())\nA = list(map(int,input().split()))\nC = collections.Counter(A)\n\nans = 0\nfor i in C.values():\n ans += int(0.5* i * (i-1))\nfor j in A:\n print(ans-C[j]+1)\n', 'from collections import deque\nS = str(input())\nQ = int(input())\nquery = [ input().split() for _ in range(Q) ]\n\ntag = False\nque = deque([S])\n\nfor i in range(Q):\n if query[i][0] == str(1):\n if tag == False:\n tag = True\n else:\n tag = False\n elif query[i][0] == str(2):\n if query[i][1] == str(1):\n if tag == False:\n que.appendleft(query[i][2])\n else:\n que.append(query[i][2])\n else:\n if tag == False:\n que.append(query[i][2])\n else:\n que.appendleft(query[i][2])\nans = "".join(que)\nif tag == True:\n ans = ans[::-1]\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s349322423', 's960184720'] | [3444.0, 42996.0] | [21.0, 548.0] | [193, 684] |
p02756 | u167681750 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\n\ns = deque(input())\nq = int(input())\nflag = 1\nfor _ in range(q):\n tfc = input().split()\n print(tfc)\n if tfc[0] == "1":\n flag *= -1\n\n elif tfc[0] == "2":\n if (tfc[1] == "1" and flag == 1) or (tfc[1] == "2" and flag == -1):\n s.appendleft(tfc[2])\n elif (tfc[1] == "1" and flag == -1) or (tfc[1] == "2" and flag == 1):\n s.append(tfc[2])\nelse:\n\n if flag == -1:\n s = list(s)[::-1]\n \nprint("".join(s))', 'from collections import deque\n\ns = deque(input())\nq = int(input())\n\nflag = 1\n\nfor _ in range(q):\n tfc = input().split()\n if tfc[0] == "1":\n flag *= -1\n\n elif tfc[0] == "2":\n if (tfc[1] == "1" and flag == 1) or (tfc[1] == "2" and flag == -1):\n s.appendleft(tfc[2])\n elif (tfc[1] == "1" and flag == -1) or (tfc[1] == "2" and flag == 1):\n s.append(tfc[2])\nelse:\n\n if flag == -1:\n s = list(s)[::-1]\n\nprint("".join(s))'] | ['Wrong Answer', 'Accepted'] | ['s030860451', 's319731835'] | [13044.0, 10100.0] | [1615.0, 431.0] | [496, 475] |
p02756 | u169138653 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ndef main():\n input=sys.stdin.readline\n s=input()\n q=int(input())\n ok=1\n for i in range(q):\n query=list(input().split())\n if query[0]=='1':\n ok=(ok+1)%2\n else:\n f,c=query[1],query[2]\n if ok:\n if f=='1':\n s=c+s\n else:\n s+=c\n else:\n if f=='1':\n s=s+c\n else:\n s=c+s\n if ok:\n print(s)\n else:\n print(s[::-1])\nif __name__=='__main__':\n main()", "from collections import deque\ndef main():\n s=deque(list(input()))\n q=int(input())\n ok=1\n for i in range(q):\n query=list(input().split())\n if query[0]=='1':\n ok=(ok+1)%2\n else:\n f,c=query[1],query[2]\n if ok:\n if f=='1':\n s.appendleft(c)\n else:\n s.append(c)\n else:\n if f=='1':\n s.append(c)\n else:\n s.appendleft(c)\n s=list(s)\n if ok:\n print(''.join(s))\n else:\n print(''.join(s[::-1]))\nif __name__=='__main__':\n main()"] | ['Wrong Answer', 'Accepted'] | ['s019575210', 's583745501'] | [4144.0, 8548.0] | [2103.0, 451.0] | [453, 521] |
p02756 | u169350228 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import numpy as np\ns = input()\nq = int(input())\nrbef = []\naft = []\nsgn = 1\nfor i in range(q):\n qi = np.array(input().split(),dtype=str)\n if qi[0] == "1":\n sgn *= -1\n else:\n if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):\n rbef.append(qi[2])\n else:\n aft.append(qi[2])\n\n\nbef = \'\'.join(list(reversed(rbef)))\nans = (\'\'.join(reversed(rbef))+s).join(aft)\n\nif sgn == 1:\n print(ans)\nelse:\n rans = \'\'.join(list(reversed(ans)))\n print(rans)\n', 'import numpy as np\ns = input()\nq = int(input())\nsgn = 1\nfor i in range(q):\n qi = np.array(input().split(),dtype=str)\n if qi[0] == "1":\n sgn *= -1\n else:\n if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):\n s = qi[2] + s\n else:\n s = s + qi[2]\n\n\'\'\'\nif sgn == 1:\n print(s)\nelse:\n news = \'\'.join(list(reversed(s)))\n print(news)\n\'\'\'\n', 'import numpy as np\ns = input()\nq = int(input())\nrbef = []\naft = []\nsgn = 1\nfor i in range(q):\n qi = np.array(input().split(),dtype=str)\n if qi[0] == "1":\n sgn *= -1\n else:\n if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):\n rbef.append(qi[2])\n else:\n aft.append(qi[2])\n\n\n', 'import numpy as np\ns = input()\nq = int(input())\nrbef = str()\naft = str()\nsgn = 1\nfor i in range(q):\n qi = np.array(input().split(),dtype=str)\n if qi[0] == "1":\n sgn *= -1\n else:\n if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):\n rbef += qi[2]\n else:\n aft += qi[2]\n\n\n', 'import numpy as np\ns = input()\nq = int(input())\nrbef = []\naft = []\nsgn = 1\nfor i in range(q):\n qi = np.array(input().split(),dtype=str)\n if qi[0] == "1":\n sgn *= -1\n else:\n if (qi[1] == "1" or sgn == -1) and (qi[1] == "2" or sgn == 1):\n rbef.append(qi[2])\n else:\n aft.append(qi[2])\n\nbef = "".join(reversed(rbef))\ntaft = "".join(aft)\nans = bef + s + taft\n\nif sgn == 1:\n print(ans)\nelse:\n rans = \'\'.join(list(reversed(ans)))\n print(rans)\n'] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s189263146', 's556331409', 's649205737', 's911111074', 's964444957'] | [36420.0, 14636.0, 34580.0, 14920.0, 36068.0] | [1629.0, 2108.0, 1634.0, 2108.0, 1669.0] | [507, 401, 486, 482, 497] |
p02756 | u170410075 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s=input()\nn=int(input())\nr=-1\nf=[]\nb=[]\nfor i in range(n):\n q=input().split()\n if q[0]=='1':\n r*=-1\n else:\n t=int(q[1])\n if t*r==-1 or t*r==2 :\n f.append(q[2])\n else:\n b.append(q[2])\ns=f[::-1]+s+b\nif r==1:\n s=s[::-1]\nprint(s)\n \n", "s=input()\nn=int(input())\nr=-1\nfor i in range(n):\n q=input().split()\n if q[0]=='1':\n r*=-1\n else:\n t=int(q[1])\n if t*r==(-1 or 2):\n s=q[2]+s\n else:\n s=s+q[2]\nif r==1:\n s=s[::-1]\nprint(s)\n \n", "s=input()\nn=int(input())\nr=-1\nf=[]\nb=[]\nfor i in range(n):\n q=input().split()\n if q[0]=='1':\n r*=-1\n else:\n t=int(q[1])\n if t*r==-1 or t*r==2 :\n f.append(q[2])\n else:\n b.append(q[2])\nf=''.join(f)\nb=''.join(b)\ns=f[::-1]+s+b\nif r==1:\n s=s[::-1]\nprint(s)\n \n"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s222623010', 's524839773', 's556859886'] | [6088.0, 4068.0, 4936.0] | [498.0, 2104.0, 488.0] | [301, 261, 327] |
p02756 | u173148629 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\nS=input()\nQ=int(input())\n\nX=deque(list(S))\nf=1\nfor _ in range(Q):\n t,ff,c=input().split()\n if t=="1":\n f*=-1\n else:\n if ff=="1":\n if f==1:\n X.appendleft(c)\n else:\n X.append(c)\n else:\n if f==-1:\n X.appendleft(c)\n else:\n X.append(c)\n\nif f==-1:\n X.reverse()\n\nprint("".join(X))', 'from collections import deque\nS=input()\nQ=int(input())\n\nX=deque(list(S))\nf=1\nfor _ in range(Q):\n A=list(input().split())\n if A[0]=="1":\n f*=-1\n else:\n if A[1]=="1":\n if f==1:\n X.appendleft(A[2])\n else:\n X.append(A[2])\n else:\n if f==-1:\n X.appendleft(A[2])\n else:\n X.append(A[2])\n\nif f==-1:\n X.reverse()\n\nprint("".join(X))'] | ['Runtime Error', 'Accepted'] | ['s369383937', 's685032535'] | [8548.0, 8548.0] | [394.0, 484.0] | [440, 458] |
p02756 | u175590965 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = inmput()\nq = int(ionput())\nh,t = [],[]\np = 0\n\nfor i in range(q):\n c = input().split()\n if c[0] ==\'1\':\n h,t = t,h\n p = 1-p\n else:\n if c[1] ==\'1\':\n h.append(c[2])\n else:\n t.append(c[2])\nif p ==1:\n s = s[::-1]\nprint("".join(h[::-1])+s+"".join(t))', 's = input()\nq = int(ionput())\nh,t = [],[]\np = 0\n\nfor i in range(q):\n c = input().split()\n if c[0] ==\'1\':\n h,t = t,h\n p = 1-p\n else:\n if c[1] ==\'1\':\n h.append(c[2])\n else:\n t.append(c[2])\nif p ==1:\n s = s[::-1]\nprint("".join(h[::-1])+s+"".join(t))', 's = input()\nq = int(input())\nh,t = [],[]\np = 0\n\nfor i in range(q):\n c = input().split()\n if c[0] ==\'1\':\n h,t = t,h\n p = 1-p\n else:\n if c[1] ==\'1\':\n h.append(c[2])\n else:\n t.append(c[2])\nif p ==1:\n s = s[::-1]\nprint("".join(h[::-1])+s+"".join(t))'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s119546188', 's271550142', 's902783533'] | [9008.0, 8996.0, 12144.0] | [31.0, 28.0, 283.0] | [309, 308, 307] |
p02756 | u185405877 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nn=int(input())\ndef asd(s,m):\n if len(m)==1:\n return s[::-1]\n else:\n if m[1]=="2":\n return s+m[2]\n else:\n return m[2]+s\nfor i in range(n):\n k= input().split()\n asd(s,k)\nprint(s)', 's=input()\nn=int(input())\nfor i in range(n):\n k= input().split()\n if k=="1":\n s = s[::-1] \n else:\n if k[1]=="2":\n s=s+k[2]\n else:\n s=k[2]+s\nprint(s)', 'S = input()\nQ = int(input())\nreverseCount = 0\npre = ""\npro = ""\nfor _ in range(Q):\n query = input()\n if len(query) == 1:\n reverseCount += 1\n else:\n _, F, C = query.split(" ")\n if (int(F) + reverseCount) % 2 == 1:\n pre = C + pre\n else:\n pro = pro + C\nS = pre + S + pro\nif reverseCount % 2 == 0:\n print(S)\nelse:\n print(S[::-1])'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s748801880', 's760269778', 's527286178'] | [3316.0, 3852.0, 4616.0] | [2104.0, 2103.0, 1672.0] | [241, 199, 390] |
p02756 | u185424824 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def toku()\n S = input()\n Q = int(input())\n s = [S[0]]\n A = []\n count = 0\n for i in range(Q):\n A += [input().split()]\n for i in range(Q):\n if int(A[i][0]) == 2:\n if count % 2 == 1:\n s = s[::-1]\n count = 0\n if int(A[i][1]) == 1:\n s = [A[i][2]] + s\n else:\n s = s + [A[i][2]]\n else:\n count += 1\n if i == Q-1:\n if count % 2 == 1:\n s = s[::-1]\n\n\n result = ''.join(s)\n print(result)\ntoku()\n", "def toku()\n S = input()\n Q = int(input())\n s = [S[0]]\n A = []\n count = 0\n for i in range(Q):\n A += [input().split()]\n for i in range(Q):\n if int(A[i][0]) == 2:\n if count % 2 == 1:\n s = s[::-1]\n count = 0\n if int(A[i][1]) == 1:\n s = [A[i][2]] + s\n else:\n s = s + [A[i][2]]\n else:\n count += 1\n if i == Q-1:\n if count % 2 == 1:\n s = s[::-1]\n\n\n result = ''.join(s)\n print(result)\n", 'from collections import deque\nS = input()\nS = deque(S)\nN = int(input())\n\nrev = 0\n\nfor i in range(N):\n Q = input().split()\n if Q[0] == "1":\n rev += 1\n rev %= 2\n else:\n if (rev + int(Q[1])) % 2 == 1:\n S.appendleft(Q[2])\n else:\n S.append(Q[2])\nS = "".join(S)\nif rev == 1:\n S = S[::-1]\nprint(S)\n \n '] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s304538782', 's422050341', 's404441217'] | [2940.0, 2940.0, 8436.0] | [17.0, 18.0, 539.0] | [468, 461, 331] |
p02756 | u188827677 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\ns = input()\nq = int(input())\n\ns = deque(s)\nt = 0\nfor _ in range(q):\n query = list(map(str, input().split()))\n if query[0] == "1": t = 1 - t\n else:\n if t == 0:\n if query[1] == "1": s.appendleft(query[2])\n elif query[1] == "2": s.append(query[2])\n elif t == 1:\n if query[1] == "1": s.append(query[2])\n elif query[1] == "2": s.appendleft(query[2])\nif query[0] == "1":print("".join(s)[::-1])\nelse: print("".join(s))', 'from collections import deque\ns = deque(input())\nq = int(input())\n\nflag = 0\nfor _ in range(q):\n query = list(map(str, input().split()))\n if query[0] == "1": flag = 1 - flag\n else:\n if query[1] == "1":\n if flag == 0: s.appendleft(query[2])\n else: s.append(query[2])\n else:\n if flag == 0: s.append(query[2])\n else: s.appendleft(query[2])\n\nif query[0] == "1": s.reverse()\nprint(*s, sep="")', 'from collections import deque\ns = deque(input())\nq = int(input())\n\nflag = 0\nfor _ in range(q):\n query = list(map(str, input().split()))\n if query[0] == "1": flag = 1 - flag\n else:\n if query[1] == "1":\n if flag == 0: s.appendleft(query[2])\n else: s.append(query[2])\n else:\n if flag == 0: s.append(query[2])\n else: s.appendleft(query[2])\n\nif flag == 1: s.reverse()\nprint(*s, sep="")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s040364921', 's717571165', 's047602646'] | [14360.0, 16640.0, 16688.0] | [414.0, 460.0, 452.0] | [470, 415, 409] |
p02756 | u189023301 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\nimport sys\nsys.setrecursionlimit(10 ** 7)\nreadline = sys.stdin.readline\n\n\ndef main():\n a = input()\n d = deque(a)\n n = int(input())\n for i in range(n):\n j = list(readline().split())\n if len(j) == 3 and j[1] == "1":\n d.appendleft(j[2])\n elif len(j) == 3 and j[1] == "2":\n d.append(j[2])\n else:\n d.reverse()\n ans = ""\n e = list(d)\n for j in e:\n ans = ans + j\n print(ans)\n', 'from collections import deque\nimport sys\nreadline = sys.stdin.readline\n\n\ndef main():\n a = input()\n d = deque(a)\n n = int(input())\n flagr = True\n for i in range(n):\n j = list(readline().split())\n if len(j) == 1:\n flagr = not flagr\n elif int(j[1] == "1") ^ flagr:\n d.append(j[2])\n else:\n d.appendleft(j[2])\n if not flagr:\n d.reverse()\n print("".join(d))\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s694595978', 's773929928'] | [3316.0, 8564.0] | [22.0, 215.0] | [490, 481] |
p02756 | u189485655 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\n\ns=list(input())\nq=int(input())\n\nre=False\nfor i in range(1,q+1):\n q_i=sys.stdin.readline().rstrip().split()\n if q_i[0]=="1":\n ~re\n else:\n if q_i[1]=="1" and re==True:\n s=[q_i[2]]+s\n elif q_i[1]=="2" and re==False:\n s=[q_i[2]]+s\n else:\n s=s+[q_i[2]]\n\nif re==True:\n s=s[::-1]\n\ns="".join(s)\nprint(s)', 'import sys\n\ns=list(input())\nq=int(input())\n\nre=False\nfor i in range(1,q+1):\n q_i=sys.stdin.readline().rstrip().split()\n if q_i[0]=="1":\n re= not re\n else:\n if q_i[1]=="1" and re==True:\n s=[q_i[2]]+s\n elif q_i[1]=="2" and re==False:\n s=[q_i[2]]+s\n else:\n s=s+[q_i[2]]\n\nif re==True:\n s=s[::-1]\n\ns="".join(s)\nprint(s)', 'import sys\n\ns=list(input())\nq=int(input())\n\nre=False\nfor i in range(1,q+1):\n q_i=sys.stdin.readline().rstrip().split()\n if q_i[0]=="1":\n re= ~re\n else:\n if q_i[1]=="1" and re==True:\n s=[q_i[2]]+s\n elif q_i[1]=="2" and re==False:\n s=[q_i[2]]+s\n else:\n s=s+[q_i[2]]\n\nif re==True:\n s=s[::-1]\n\ns="".join(s)\nprint(s)', 'from collections import deque\n\ns=list(input())\ns=deque(s)\nq=int(input())\n\nre=False\nfor i in range(1,q+1):\n q_i=input().split()\n if q_i[0]=="1":\n re= not re\n else:\n if q_i[1]=="1" and re==False:\n s.appendleft(q_i[2])\n elif q_i[1]=="2" and re==True:\n s.appendleft(q_i[2])\n else:\n s.append(q_i[2])\n\ns=list(s)\n\nif re==True:\n s=s[::-1]\n\ns="".join(s)\nprint(s)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s129047907', 's701851807', 's948367259', 's476120133'] | [5588.0, 7496.0, 7496.0, 10084.0] | [2108.0, 2104.0, 2104.0, 403.0] | [380, 387, 384, 426] |
p02756 | u189487046 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\n\nsl = ['']*(q*4)\nprint(sl)\nsl[q*2] = s\nm = q*2-1\nu = q*2+1\nrev = False\nfor _ in range(q):\n query = input().split()\n\n if query[0] == '1' and not(rev):\n rev = True\n elif query[0] == '1' and rev:\n rev = False\n\n elif query[0] == '2' and query[1] == '1' and not(rev):\n #s = ''.join([query[2], s])\n sl[m] = query[2]\n m -= 1\n\n elif query[0] == '2' and query[1] == '1' and rev:\n \n sl[u] = query[2]\n u += 1\n\n elif query[0] == '2' and query[1] == '2' and not(rev):\n \n sl[u] = query[2]\n u += 1\n\n elif query[0] == '2' and query[1] == '2' and rev:\n #s = ''.join([query[2], s])\n sl[m] = query[2]\n m -= 1\n\nif rev:\n sl.reverse()\n print(''.join(sl))\nelse:\n print(''.join(sl))\n", "s = input()\nq = int(input())\n\nsl = ['']*(q*2+2)\nsl[q] = s\nm = q-1\nu = q+1\nrev = False\nfor _ in range(q):\n query = input().split()\n\n if query[0] == '1' and not(rev):\n rev = True\n elif query[0] == '1' and rev:\n rev = False\n\n elif query[0] == '2' and query[1] == '1' and not(rev):\n sl[m] = query[2]\n m -= 1\n\n elif query[0] == '2' and query[1] == '1' and rev:\n sl[u] = query[2]\n u += 1\n\n elif query[0] == '2' and query[1] == '2' and not(rev):\n sl[u] = query[2]\n u += 1\n\n elif query[0] == '2' and query[1] == '2' and rev:\n sl[m] = query[2]\n m -= 1\n\nif rev:\n sl[q] = s[::-1]\n sl.reverse()\n print(''.join(sl))\nelse:\n print(''.join(sl))\n"] | ['Wrong Answer', 'Accepted'] | ['s088560742', 's261854160'] | [18928.0, 7284.0] | [510.0, 454.0] | [870, 732] |
p02756 | u190873802 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['# coding: utf-8\n# Your code here!\nS = input()\nQ = int(input())\nQlist = [list(input().split()) for _ in range(Q)]\n\n#print(S)\nRcount="NO"\ni=0\nwhile i<Q:\n if Qlist[i][0]=="1":\n #S=S[::-1]\n Rcount="YES"\n else:\n check=Qlist[i][2]\n if Qlist[i][1]=="1" and Rcount=="NO":\n S=check+S\n elif Qlist[i][1]=="1" and Rcount=="YES":\n S=S+check\n elif Qlist[i][1]=="2" and Rcount=="NO":\n S=S+check\n elif Qlist[i][1]=="2" and Rcount=="YES":\n S=check+S\n i+=1\n\nif Rcount=="YES":\n print(S[::-1])\nelse:\n print(S)', 'S = input()\nQ = int(input())\nQlist = [list(input().split()) for _ in range(Q)]\ntoplist=[]\nbacklist=[]\nFlag=1\n\ni=0\nwhile i<Q:\n if Qlist[i][0]=="1":\n Flag*=-1\n else:\n #check=Qlist[i][2]\n if Qlist[i][1]=="1" and Flag==-1:\n backlist.append(Qlist[i][2])\n elif Qlist[i][1]=="1" and Flag==1:\n toplist.append(Qlist[i][2])\n elif Qlist[i][1]=="2" and Flag==-1:\n toplist.append(Qlist[i][2])\n elif Qlist[i][1]=="2" and Flag==1:\n backlist.append(Qlist[i][2])\n i+=1\nif Flag==1:\n #print(toplist)\n #print(S)\n #print(backlist)\n print("".join(toplist[::-1])+S+"".join(backlist))\nelse:\n #print(backlist[::-1])\n #print(S)\n #print(toplist[::-1])\n print("".join(backlist[::-1])+S[::-1]+"".join(toplist))'] | ['Wrong Answer', 'Accepted'] | ['s207321833', 's767248985'] | [31940.0, 33028.0] | [2106.0, 578.0] | [597, 800] |
p02756 | u196746947 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n s=input()\n q=int(input())\n queryy=[]\n sent="a"\n back="a"\n for i in range(q):\n queryy.append(tuple(input().split()))\n check=-1\n for query in queryy:\n # print(query)\n if query[0]=="1":\n check*=-1\n else:\n if query[1]=="1":\n if check==-1:\n sent+=str(query[2])\n # s=str(query[2])+s\n else:\n back+=str(query[2])\n # s+=str(query[2])\n \n else:\n if check==-1:\n back+=str(query[2])\n #s+=str(query[2])\n else:\n sent+=str(query[2])\n #s=str(query[2])+s\n s=s[::-1]\n # print(type(sent))\n #if sent[0]=="1":\n # sent=sent[1:]\n sent=sent[::-1]\n sent=sent[:len(sent)-1]\n if back[0]=="1":\n back=back[1:]\n\n if check==1:\n s=sent+s+back \n print(s[::-1]) \n else:\n s=sent+s+back\n print(s)\n\nif __name__=="__main__":\n main() ', 'def main():\n s=input()\n q=int(input())\n queryy=[]\n sent="1"\n back="1"\n for i in range(q):\n queryy.append(tuple(input().split()))\n check=-1\n for query in queryy:\n # print(query)\n if query[0]=="1":\n check*=-1\n else:\n if query[1]=="1":\n if check==-1:\n sent+=query[2]\n # s=str(query[2])+s\n else:\n back+=query[2]\n # s+=str(query[2])\n \n else:\n if check==-1:\n back+=query[2]\n #s+=str(query[2])\n else:\n sent+=query[2]\n #s=str(query[2])+s\n s=s[::-1]\n # print(type(sent))\n if sent[0]=="1"\n sent=sent[1:]\n sent=sent[::-1]\n if back[0]=="1"\n back=back[1:]\n\n if check==1:\n \n print((sent+s+back)[::-1]) \n else:\n print(sent+s+back)\n\nif __name__=="__main__":\n main() \n', 'def main():\n s=input()\n q=int(input())\n queryy=[]\n sent="a"\n back="a"\n for i in range(q):\n queryy.append(tuple(input().split()))\n check=-1\n for query in queryy:\n # print(query)\n if query[0]=="1":\n check*=-1\n else:\n if query[1]=="1":\n if check==-1:\n sent+=str(query[2])\n # s=str(query[2])+s\n else:\n back+=str(query[2])\n # s+=str(query[2])\n \n else:\n if check==-1:\n back+=str(query[2])\n #s+=str(query[2])\n else:\n sent+=str(query[2])\n #s=str(query[2])+s\n # print(type(sent))\n #if sent[0]=="1":\n # sent=sent[1:]\n sent=sent[1:]\n sent=sent[::-1] \n back=back[1:]\n\n if check==1:\n s=sent+s+back \n print(s[::-1]) \n else:\n s=sent+s+back\n print(s)\n\nif __name__=="__main__":\n main() '] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s180207022', 's452881166', 's855711400'] | [20180.0, 3064.0, 20156.0] | [459.0, 18.0, 450.0] | [1093, 1030, 1048] |
p02756 | u198905553 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n \nS = deque(input())\nQ = int(input())\n \nQ_list = [list(map(str, input().split())) for i in range(Q)]\n \nfor i in range(Q): \n if int(Q_list[i][0]) == 1:\n if len(S) >= 2:\n S = S[::-1]\n \n else:\n F = Q_list[i][1]\n C = Q_list[i][2]\n \n if int(F) == 1:\n S.appendleft(C)\n else:\n S.append(C)\n \nprint(''.join(S))", "from collections import deque\n \nS = deque(input())\nQ = int(input())\n \nQ_list = [list(map(str, input().split())) for i in range(Q)]\n \nrev = False\n \nfor i in range(Q):\n if int(Q_list[i][0]) == 1:\n rev = not rev\n \n else:\n F = Q_list[i][1]\n C = Q_list[i][2]\n \n if rev ^ (int(F) == 1): \n S.appendleft(C) \n else:\n S.append(C)\n \nif rev: \n S.reverse()\n \nprint(''.join(S))"] | ['Runtime Error', 'Accepted'] | ['s823504305', 's185970832'] | [44788.0, 44660.0] | [716.0, 746.0] | [387, 581] |
p02756 | u199830845 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['N, A, B = map(int, input().split())\n\ndivision = N // (A + B)\ncount = division * A\n\ncount += N - division * (A + B) if A > N - division * (A + B) else A\nprint(count)', "import sys\nfrom collections import deque\nS = deque(input())\nQ = int(input())\n\n\nreverse = 0\n\nfor query in sys.stdin:\n if query[0] == '1': \n reverse = 1 - reverse\n\n else:\n _, f, c = query.split()\n is_append_left = (reverse + int(f)) % 2\n if is_append_left:\n S.appendleft(c) \n else:\n S.append(c)\n\nif reverse: \n S.reverse()\n\nprint(''.join(S))"] | ['Runtime Error', 'Accepted'] | ['s351443749', 's106193551'] | [3188.0, 8436.0] | [18.0, 247.0] | [164, 692] |
p02756 | u201986772 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns=deque(list(input()))\nflag=True\nfor i in range(int(input())):\n dir=input().split()\n if int(dir[0])==1:flag=False\n else:\n if int(dir[1])==1:\n if flag:s.appendleft(dir[2])\n else:s.append(dir[2])\n else:\n if flag:s.append(dir[2])\n else:s.appendleft(dir[2])\ns=list(s)\nif flag==False:s.reverse()\nprint(*s,sep='')", "from collections import deque\n\ns=deque(list(input()))\nflag=0\nfor i in range(int(input())):\n dir=input().split()\n if int(dir[0])==1:flag+=1\n else:\n if int(dir[1])==1:\n if flag%2==0:s.appendleft(dir[2])\n else:s.append(dir[2])\n else:\n if flag%2==0:s.append(dir[2])\n else:s.appendleft(dir[2])\ns=list(s)\nif flag%2==1:s.reverse()\nprint(*s,sep='')"] | ['Wrong Answer', 'Accepted'] | ['s003511513', 's274137078'] | [16468.0, 16320.0] | [396.0, 397.0] | [367, 369] |
p02756 | u203383537 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns=input()\nn=int(input())\nq=deque()\nq.append(s)\nf=0\nfor i in range(n):\n t=list(input().split())\n if int(t[0])==1:\n f+=1\n else:\n if f%2==0:\n if t[1]=='1' :\n q.appendleft(t[2])\n else:\n q.append(t[2])\n else:\n if t[2]=='2':\n q.appendleft(t[2])\n else: \n q.append(t[2])\nif f%2==1:\n q=reversed(q)\n\nans=''.join(q)\nprint(ans) ", "s=input()\nq=int(input())\nans=s\nprint(''.join(list(reversed(s))))\nfor i in range(q):\n a=list(input().split())\n if a[0]=='1':\n ans=''.join(list(reversed(ans)))\n elif a[0]=='2' and a[1]=='1':\n ans=a[2]+ans\n else:\n ans=ans+a[2]\n\nprint(ans) \n ", 'from collections import deque\n\ns = input()\nQ = int(input())\n\nl = deque()\nl.append(s)\n\nrev = True\nfor i in range(Q):\n q = list(input().split())\n if q[0] == "1":\n rev = not rev\n else:\n if rev:\n if q[1] == "1":\n l.appendleft(q[2])\n else:\n l.append(q[2])\n else:\n if q[1] == "1":\n l.append(q[2])\n else:\n l.appendleft(q[2])\n\nans = "" \nfor i in l:\n ans += i\n\nif not rev:\n print(ans[::-1])\nelse:\n print(ans)'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s196267021', 's960664591', 's118756189'] | [6900.0, 6516.0, 11644.0] | [572.0, 2104.0, 338.0] | [490, 285, 545] |
p02756 | u203669169 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['#! /usr/bin/env python3\n\nfrom fractions import gcd\nfrom collections import Counter, deque, defaultdict\nfrom heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge\nfrom bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort\nfrom itertools import accumulate, product, permutations, combinations, combinations_with_replacement\n\nS = input()\nQ = int(input())\n\ndire = 0\nfront = []\nback = []\n\nfor i in range(Q):\n quary = [_ for _ in input().split()]\n if len(quary) == 1:\n T = quary[0]\n dire += 1\n else:\n T, F, C = quary\n if F == "1":\n if dire % 2 == 0:\n front += [C]\n else:\n back += [C]\n else:\n if dire % 2 == 1:\n front += [C]\n else:\n back += [C]\n\nfor f in front:\n S = f + S\nfor b in back:\n S = S + b\n\nif dire % 2 == 1:\n print(S[::-1])\nelse:\n print(S)', 's = input()\nn = int(input())\n\nct = 0\n\nfor i in range(n):\n p = input().split()\n\n if p[0] == \'1\':\n ct += 1\n else:\n if p[1] == "2":\n ct += 1\n \n if ct % 2 :\n s = s + p[2]\n else:\n s = p[2] + s\n ct = 0\n\n\nprint(s[::-1])', 's = input()\nn = int(input())\n\nct = 0\n\nfor i in range(n):\n p = input().split()\n\n if p[0] == \'1\':\n ct += 1\n else:\n if p[1] == "2":\n ct += 1\n \n if ct % 2 :\n s = s + p[2]\n else:\n s = p[2] + s\n ct = 0\n\nif ct % 2 :\n s = s[::-1]\n \nprint(s)', 's = input()\nn = int(input())\n\nct = 0\n\nfor i in range(n):\n p = input().split()\n\n if p[0] == \'1\':\n ct += 1\n else:\n if p[1] == "2":\n ct += 1\n \n if ct % 2 :\n s = s + p[2]\n else:\n s = p[2] + s\n ct = 0\n\nif ct % 2 :\n s = s[::-1]\n \nprint(s)', 'S = input()\nQ = int(input())\n\ndire = 0\nfront = ""\nback = ""\n\nfor i in range(Q):\n quary = [_ for _ in input().split()]\n if len(quary) == 1:\n T = quary[0]\n dire += 1\n else:\n T, F, C = quary\n if F == "1":\n if dire % 2 == 0:\n front += C\n else:\n back += C\n else:\n if dire % 2 == 1:\n front += C\n else:\n back += C\n\nS = front[::-1] + S + back\n\nif dire % 2 == 1:\n print(S[::-1])\nelse:\n print(S)\n'] | ['Time Limit Exceeded', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s005091847', 's492235709', 's702199240', 's743609472', 's122885890'] | [7736.0, 4068.0, 3828.0, 3832.0, 4596.0] | [2104.0, 2108.0, 2104.0, 2104.0, 591.0] | [950, 296, 322, 322, 540] |
p02756 | u207137484 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\n\ndeq=deque()\ndeq.append(input())\nq=int(input())\nx=True\nfor i in range(q):\n\ta=input()\n\tif a[0]=="1":\n\t\tx = not x\n\t\tprint(x)\n\telif a[2]=="1":\n\t\tif x%2!=0:\n\t\t\tdeq.appendleft(a[4])\n\t\telse:\n\t\t\tdeq.append(a[4])\n\telse:\n\t\tif x%2!=0:\n\t\t\tdeq.append(a[4])\n\t\telse:\n\t\t\tdeq.appendleft(a[4])\nif x==True:\n\tc="".join(deq)\nelse:\n\tdeq.reverse()\n\tc="".join(deq)\nprint(c)\n', 'from collections import deque\n\ndeq=deque()\nk = input()\nfor i in range(len(k)):\n\tdeq.append(k[i])\nq=int(input())\nx=True\nfor i in range(q):\n\ta=input()\n\tif a[0]=="1":\n\t\tx = not x\n\telif a[2]=="1":\n\t\tif x==True:\n\t\t\tdeq.appendleft(a[4])\n\t\telse:\n\t\t\tdeq.append(a[4])\n\telse:\n\t\tif x==True:\n\t\t\tdeq.append(a[4])\n\t\telse:\n\t\t\tdeq.appendleft(a[4])\nif x==True:\n\tc="".join(deq)\nelse:\n\tdeq.reverse()\n\tc="".join(deq)\nprint(c)\n'] | ['Wrong Answer', 'Accepted'] | ['s255995896', 's109912360'] | [6900.0, 8820.0] | [669.0, 355.0] | [381, 406] |
p02756 | u207464563 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\n\nforward = [] \nbackend = [] \nreverse = 0 \n\nfor i in range(Q):\n \n s = input()\n if s.count(" ") == 0:\n reverse += 1\n else:\n s2 = s.split(" ")\n if s2[1] == \'1\':\n if reverse % 2 == 0:\n forward.append(s2[2])\n else:\n backend.append(s2[2])\n else:\n if reverse % 2 == 0:\n backend.append(s2[2])\n else:\n forward.append(s2[2])\n\n\nif reverse % 2 == 0:\n for i in forward[::-1]:\n print(i,end="")\n \n print(S,end="")\n\n for i in backend:\n print(i,end="")\nelse:\n for i in backend[::-1]:\n print(i,end="")\n \n print(S,end="")\n\n for i in forward:\n print(i,end="")', 'S = input()\nQ = int(input())\n\nforward = []\nbackend = []\nreverse = 0\n\nfor i in range(Q):\n s = input()\n s1 = list(s)\n\n if s1[0] == \'1\':\n reverse += 1\n else:\n if s1[2] == \'1\':\n if reverse % 2 == 0:\n forward.append(s1[4])\n else:\n backend.append(s1[4])\n else:\n if reverse % 2 == 0:\n backend.append(s1[4])\n else:\n forward.append(s1[4])\n\nif reverse % 2 == 0:\n for i in forward[::-1]:\n print(i, end="")\n \n print(S,end="")\n\n for i in backend:\n print(i,end="")\n\n print()\nelse:\n for i in backend[::-1]:\n print(i,end="")\n \n for i in list(S)[::-1]:\n print(i,end="")\n\n for i in forward:\n print(i,end="")\n\n print()'] | ['Wrong Answer', 'Accepted'] | ['s365687606', 's975398716'] | [7628.0, 7832.0] | [643.0, 698.0] | [1035, 861] |
p02756 | u210543511 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\n\ncnt_reverse = 0\nfor i in range(q):\n query = input()\n \n if query[0] == '1':\n cnt_reverse += 1\n elif (query[2] == '1' and cnt_reverse % 2==0) or (query[2] == '1' and cnt_reverse % 2==1):\n s = query[4] + s\n else:\n s = s + query[4]\nif cnt_reverse%2==1:\n s = s[::-1]\nprint(s)", "s = input()\nq = int(input())\n\ncnt_reverse = False\nleft = ''\nfor i in range(q):\n query = input()\n \n if query[0] == '1':\n cnt_reverse = not cnt_reverse\n elif (query[2] == '1' and not cnt_reverse) or (query[2] == '2' and cnt_reverse):\n left = left + query[4]\n\n else:\n s = s + query[4]\ns = left[::-1] + s\nif cnt_reverse:\n s = s[::-1]\nprint(s)\n"] | ['Wrong Answer', 'Accepted'] | ['s426234157', 's813655760'] | [4000.0, 4192.0] | [2104.0, 358.0] | [316, 355] |
p02756 | u213497190 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from sys import stdin\n \ndef main():\n S = list(stdin.readline().rstrip())\n Q = int(input())\n rev = 0\n head = []\n tail = []\n \n for _ in range(Q):\n q = stdin.readline()\n if q[0] == "1":\n rev = (rev+1)%2\n else:\n if q[2] == "1":\n if rev == 0:\n head.append(q[4])\n else:\n tail.append(q[4])\n else:\n if rev ==0:\n tail.append(q[4])\n else:\n head.append(q[4])\n \n if rev == 0:\n ans = "".join(head[::-1] + S + tail)\n else:\n ans = "".join(tail[::-1] + S[::-1] + head)\n \n print(ans)', "s = input()\nnq = int(input())\nflg = 0\nfront = []\nback = []\nfor i in range(nq):\n q = input()\n if len(q) == 1:\n #flg += 1\n flg = (flg+1)%2\n else:\n if flg == 0:\n if q[2] == '1':\n #front = [q[-1]] + front\n front.append(q[-1])\n else:\n #back = back + [q[-1]]\n back.append(q[-1])\n else:\n if q[2] == '1':\n #back = back + [q[-1]]\n back.append(q[-1])\n else:\n #front = [q[-1]] + front\n front.append(q[-1])\n \ns = ''.join(front) + s + ''.join(back)\nif flg % 2 == 1:\n s = s[::-1]\nprint(s)", "s = input()\nnq = int(input())\nflg = 0\nfront = []\nback = []\nfor i in range(nq):\n q = input()\n if len(q) == 1:\n #flg += 1\n flg = (flg+1)%2\n else:\n if flg == 0:\n if q[2] == '1':\n #front = [q[-1]] + front\n front.append(q[-1])\n else:\n #back = back + [q[-1]]\n back.append(q[-1])\n else:\n if q[2] == '1':\n #back = back + [q[-1]]\n back.append(q[-1])\n else:\n #front = [q[-1]] + front\n front.append(q[-1])\n \n\nif flg % 2 == 1:\n s = ''.join(back)[::-1] + s[::-1] + ''.join(front)\nelse:\n s = ''.join(front)[::-1] + s + ''.join(back)\nprint(s)"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s341981356', 's495283307', 's022997936'] | [3064.0, 5740.0, 5672.0] | [18.0, 326.0, 342.0] | [700, 693, 749] |
p02756 | u215286521 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\n\nS = str(input())\nQ = int(input())\n\nqs = [list(map(str, input().split())) for _ in range(Q)]\n\nd = deque([S])\n\ndef changeVector(vector):\n if vector:\n return False\n return True\n\ndef addLeft(vector, char):\n if vector:\n d.appendleft(char)\n return d\n d.append(char)\n return d\n\ndef addRight(vector, char):\n if vector:\n d.append(char)\n return d\n d.appendleft(char)\n return d\n\nvector = True\nfor q in qs:\n if q[0] == "1":\n vector = changeVector(vector)\n else:\n if q[1] == "1":\n d = addLeft(vector, q[2])\n else:\n d = addRight(vector, q[2])\n\nd.reverse()\n\nans = \'\'.join(list(d))\nprint(ans)\n', 'from collections import deque\n\nd = deque(input())\nQ = int(input())\n\nqs = [list(map(str, input().split())) for _ in range(Q)]\n\nvector = True\nfor q in qs:\n if q[0] == "1":\n vector = not vector\n else:\n if q[1] == "1":\n if vector:\n d.appendleft(q[2])\n else:\n d.append(q[2])\n else:\n if vector:\n d.append(q[2])\n else:\n d.appendleft(q[2])\n\nif not vector:\n d.reverse()\n\nans = \'\'.join(d)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s163382943', 's786118868'] | [42988.0, 44532.0] | [677.0, 661.0] | [716, 526] |
p02756 | u221149873 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nN = int(input())\nS = []\nfor _ in range(N):\n S.append(input().split())\n\norder = 1\nfor res in S:\n print(res)\n print(order)\n if res[0] == "1":\n order = order * - 1\n elif res[1] == "1":\n if order == 1:\n s = res[2]+s\n else:\n s = s+res[2]\n else:\n if order == 1:\n s = s+res[2]\n else:\n s = res[2]+s\n\nif order == -1:\n print(s[::-1])\nelse:\n print(s)', 'from collections import deque\ns = input().split()\nsd = deque()\nfor i in s:\n sd.append(i)\nN = int(input())\nS = []\norder = 1\nfor _ in range(N):\n res = input().split()\n if res[0] == "1":\n order = order * - 1\n elif res[1] == "1":\n if order == 1:\n sd.appendleft(res[2])\n else:\n sd.append(res[2])\n else:\n if order == 1:\n sd.append(res[2])\n else:\n sd.appendleft(res[2])\n\nsd_str="".join(list(sd))\nif order == -1:\n print(sd_str[::-1])\nelse:\n print(sd_str)'] | ['Wrong Answer', 'Accepted'] | ['s872139345', 's616793181'] | [43420.0, 6900.0] | [2106.0, 404.0] | [454, 546] |
p02756 | u223663729 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ninput = sys.stdin.readline\nS = input()\ninput()\nrev = 0\nfor line in readlines():\n q, *query, = line.split()\n if q == '1':\n rev ^= 1\n else:\n f, c = query\n if f == '1':\n if not rev:\n S = c+S\n else:\n S = S+c\n else:\n if not rev:\n S = S+c\n else:\n S = c+S\n\nprint(S if not rev else S[::-1])\n", "from collections import deque\nimport sys\nread = sys.stdin.read\nreadlines = sys.stdin.readlines\ninput = sys.stdin.readline\nS = list(input().rstrip())\nS = deque(S)\ninput()\nrev = 0\nfor line in readlines():\n q, *query, = line.split()\n if q == '1':\n rev ^= 1\n else:\n f, c = query\n if f == '1':\n if not rev:\n S.appendleft(c)\n else:\n S.append(c)\n else:\n if not rev:\n S.append(c)\n else:\n S.appendleft(c)\n\nprint(''.join(S) if not rev else ''.join(S)[::-1])\n"] | ['Wrong Answer', 'Accepted'] | ['s569762141', 's560141152'] | [23900.0, 25888.0] | [2056.0, 142.0] | [489, 589] |
p02756 | u225627575 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\nSwitch = False\nQuery = []\n\nimport collections\ndq = collections.deque(S)\n\nfor i in range(Q):\n s = input()\n if s[0] == '1':\n if Switch:\n Switch = False\n else:\n Switch = True\n if s[0] == '2':\n if s[2] == '1' and Switch==False:\n dq.appendleft(s[4])\n# S = s[4]+S\n elif s[2]=='1' and Switch==True:\n dq.append(s[4])\n# S = S+s[4]\n elif s[2] == '2' and Switch==False:\n dq.append(s[4])\n# S = S+s[4]\n else:\n# S = s[4]+S\n dq.appendleft(s[4])\n\nif Switch == False:\n print('',join(dq))\nelse:\n print(''.join(dq)[::-1])", "S = input()\nQ = int(input())\nSwitch = False\nQuery = []\n\nimport collections\ndq = collections.deque(S)\n\nfor i in range(Q):\n s = input()\n if s[0] == '1':\n if Switch:\n Switch = False\n else:\n Switch = True\n if s[0] == '2':\n if s[2] == '1' and Switch==False:\n dq.appendleft(s[4])\n# S = s[4]+S\n elif s[2]=='1' and Switch==True:\n dq.append(s[4])\n# S = S+s[4]\n elif s[2] == '2' and Switch==False:\n dq.append(s[4])\n# S = S+s[4]\n else:\n# S = s[4]+S\n dq.appendleft(s[4])\n\nif Switch == False:\n print(''.join(dq))\nelse:\n print(''.join(dq)[::-1])"] | ['Runtime Error', 'Accepted'] | ['s892307245', 's534392059'] | [8180.0, 8564.0] | [375.0, 369.0] | [702, 702] |
p02756 | u228636605 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nque2 = []\nque2.append(S)\nrv_flag= 0\nfor _ in range(Q):\n que = list(map(str, input().split()))\n if que[0] == "1":\n rv_flag = rv_flag + 1\n elif que[1] == "1":\n que2.insert(0,que[2])\n elif que[1] == "2":\n que2.append(que[2])\nif rv_flag % 2 == 1:\n que2.reverse()\nans = "".join(que2)\nprint(ans)', 'from collections import deque\n\nS = input()\nQ = int(input())\nL = ""\nR = ""\nflag = 0\n\nfor i in range(Q):\n q = list(map(str , input().split()))\n if q[0] == "1":\n if flag == 0:\n flag = 1\n else:\n flag = 0\n else:\n if q[1] == "1":\n if flag == 0:\n L.append(q[2])\n else:\n R.append(q[2])\n else:\n if flag == 0:\n R.appned(q[2])\n else:\n L.append(q[2])\nK = L[::-1] + R\n\nif flag == 0:\n print("".join(K))\nelse:\n print("".join(K[::-1]))', 'S = input()\nQ = int(input())\nfg = False\nque2 = []\nque2.append(S)\n\nfor _ in range(Q):\n que = list(map(str, input().split()))\n if que[0] == "1":\n fg = not fg\n elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :\n que2.insert(0,que[2])\n else:\n que2.append(que[2])\n \nif fg == True:\n que2.reverse()', 'from collections import deque\n\nS = input()\nQ = int(input())\nd = deque(S)\nfg = False\nfor i in range(Q):\n que = list(map(str , input().split()))\n if que[0] == "1":\n fg = True\n elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :\n q.appendleft(que[2])\n else:\n q.append(que[2])\nif fg:\n q.reverse()\nprint("".join(q))\n', 'S = input()\nQ = int(input())\nfg = False\nque2 = []\nque2.append(S)\n\nfor _ in range(Q+1):\n que = list(map(str, input().split()))\n if que[0] == "1":\n que2.reverse()\n elif que[1] == "1":\n que2.insert(0,que[2])\n elif que[1] == "2":\n que2.append(que[2])\n \nans = "".join(que2)\nprint(ans)\n', 'from collections import deque\n\nS = input()\nQ = int(input())\nq = deque(S)\nfg = False\n\nfor i in range(Q):\n que = list(map(str , input().split()))\n if que[0] == "1":\n fg = not fg\n elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :\n q.appendleft(que[2])\n else:\n q.append(que[2])\n\nif not fg:\n q.reverse()\n\nprint("".join(q))a\n\n', 'from collections import deque\n\nS = input()\nQ = int(input())\nq = deque(S)\nfg = False\nfor i in range(Q):\n que = list(map(str , input().split()))\n if que[0] == "1":\n fg = True\n elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :\n q.appendleft(que[2])\n else:\n q.append(que[2])\nif fg:\n q.reverse()\nprint("".join(q))\n', 'S = input()\nQ = int(input())\nque2 = []\nque2.append(S)\n\nfor _ in range(Q):\n que = list(map(str, input().split()))\n if que[0] == "1":\n que2.reverse()\n elif que[1] == "1":\n que2.insert(0,que[2])\n elif que[1] == "2":\n que2.apend(que[2])\nprint(que2)', 'from collections import deque\n\nS = input()\nQ = int(input())\nq = deque(S)\nfg = False\nfor i in range(Q):\n que = list(map(str , input().split()))\n if que[0] == "1":\n fg = not fg\n elif (que[1] == "1" and fg == False) or (que[1] == "2" and fg == True) :\n q.appendleft(que[2])\n else:\n q.append(que[2])\nif fg:\n q.reverse()\nprint("".join(q))\n\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s196376685', 's237458047', 's358313413', 's372383326', 's413257057', 's722919897', 's751709343', 's910480936', 's493950294'] | [4208.0, 3572.0, 4208.0, 4212.0, 4092.0, 3064.0, 8820.0, 3188.0, 8692.0] | [2104.0, 22.0, 2104.0, 23.0, 2104.0, 17.0, 676.0, 18.0, 668.0] | [354, 588, 354, 368, 320, 379, 368, 277, 371] |
p02756 | u230117534 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = [input()]\nq = int(input().strip())\n\nfor i in range(q):\n query = input()\n if query[0] == "1":\n S.reverse()\n elif query[0] == "2":\n query = query.strip().split(" ")\n if query[1] == "1":\n S.insert(query[2])\n else:\n S.append(query[2])\n\nprint("".join(S))', 'from collections import deque\n\nS = deque(input())\nq = int(input().strip())\n\n\nrev_count = 0\nfor i in range(q):\n query = input()\n if query[0] == "1":\n rev_count += 1\n elif query[0] == "2":\n query = query.strip().split(" ")\n if rev_count & 1 == 1:\n if query[1] == "1":\n S.append(query[2])\n else:\n S.appendleft(query[2])\n else:\n if query[1] == "1":\n S.appendleft(query[2])\n else:\n S.append(query[2])\n\nif rev_count & 1 == 1:\n S.reverse()\n\nprint("".join(S))'] | ['Runtime Error', 'Accepted'] | ['s534503482', 's988040216'] | [3188.0, 8692.0] | [17.0, 495.0] | [278, 515] |
p02756 | u232873434 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nS = deque([input()])\n\ndic = 1\nQ = int(input())\nfor i in range(0,Q):\n Query = input()\n if Query == '1':\n dic = 1*(-1)\n else:\n T, F, C = Query.split()\n if (F*dic == 2) or (F*dic == -1):\n S.append(C)\n else:\n S.appendleft(C)\nprint(''.join(list(S)[::dic]))", "from collections import deque\nS = deque([str for str in input()])\ndic = 1\nQ = int(input())\nfor i in range(0,Q):\n Query = input()\n if Query == '1':\n dic = dic*(-1)\n else:\n T, F, C = Query.split()\n if (int(F)*dic == 2) or (int(F)*dic == -1):\n S.append(C)\n else:\n S.appendleft(C)\nprint(''.join(list(S)[::dic]))"] | ['Wrong Answer', 'Accepted'] | ['s995526891', 's532948857'] | [8172.0, 10724.0] | [455.0, 544.0] | [340, 366] |
p02756 | u235598818 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n from collections import deque\n S=input()\n Q=int(input())\n A=[input().split() for _ in range(Q)]\n d=deque(S)\n for x in A:\n if x[0]=="1":\n d.reverse()\n else:\n if x[1]=="1":\n d.appendleft(x[2])\n else:\n d.append(x[2])\n\n print("".join(d)) \n\n print(-1) \nif __name__ == \'__main__\':\n main()\n\n', 'def main():\n from collections import deque\n import sys\n def input():\n return sys.stdin.readline()[:-1]\n S=input()\n Q=int(input())\n A=[input().split() for _ in range(Q)]\n d=deque(S)\n \n d_left=d.appendleft\n d_right=d.append\n j=["1","2"]\n k=0\n j_re=j.reverse\n for x in A:\n if x[0]=="1":\n j_re()\n k+=1\n else:\n if x[1]==j[0]:\n d_left(x[2])\n else:\n d_right(x[2])\n if k%2==1:\n d.reverse()\n print("".join(d)) \n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s988411574', 's561883609'] | [44660.0, 44652.0] | [2106.0, 226.0] | [407, 594] |
p02756 | u235783479 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | [' S = input()\n Q = int(input())\n \n # print(S, Q)\n \n queries = []\n for i in range(Q):\n query = input()\n queries.append(query)\n \n from collections import deque\n slist = deque()\n\tslist.append(S)\n for query in queries:\n if query == "1":\n isReversed = not isReversed\n else:\n t, f, c = query.split()\n if f == \'1\':\n if isReversed:\n slist.append(c)\n else:\n slist.appendleft(c)\n else:\n if isReversed:\n slist.appendleft(c)\n else:\n slist.append(c)\n \n if isReversed:\n slist.reverse()\n print("".join(slist))', '\nS = input()\nQ = int(input())\n\n# print(S, Q)\n\nqueries = []\nfor i in range(Q):\n query = input()\n queries.append(query)\n\nfrom collections import deque\nslist = deque()\nslist.append(S)\nisReversed = False\nfor query in queries:\n if query == "1":\n isReversed = not isReversed\n else:\n t, f, c = query.split()\n if f=="1"\n if isReversed:\n slist.append(c)\n else:\n slist.appendleft(c)\n else:\n if isReversed:\n slist.appendleft(c)\n else:\n slist.append(c)\nif isReversed:\n slist.reverse()\n\nprint("".join(slist))\n', '\nS = input()\nQ = int(input())\n\n# print(S, Q)\n\nqueries = []\nfor i in range(Q):\n query = input()\n queries.append(query)\n\nfrom collections import deque\nslist = deque(list(S))\nisReversed = False\nfor query in queries:\n if query == "1":\n isReversed = not isReversed\n else:\n t, f, c = query.split()\n if f == \'1\':\n if isReversed:\n slist.append(c)\n else:\n slist.appendleft(c)\n else:\n if isReversed:\n slist.appendleft(c)\n else:\n slist.append(c)\n\nif isReversed:\n slist.reverse()\nprint("".join(slist))\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s468488581', 's796473230', 's158674027'] | [2940.0, 2940.0, 21224.0] | [17.0, 17.0, 368.0] | [754, 643, 637] |
p02756 | u236823931 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['if __name__ == \'__main__\':\n d = input()\n n = int(input())\n for _ in range(n):\n q = input()\n d = d[::-1] if q[0] == (\'1\') else d = q[-1]+d if q[:3] == ("2 1") else d=d+q[-1] \n print(d)', 'if __name__ == \'__main__\':\n d = input()\n n = int(input())\n qs = [input() for e in range(n)]\n s = []\n e = []\n r = False\n for q in qs:\n if q == \'1\':\n r = not(r)\n elif q.startswith("2 1"):\n e.append(q[-1]) if r else s.append(q[-1])\n else:\n s.append(q[-1]) if r else e.append(q[-1])\n print("".join(e[::-1]) + d[::-1] + "".join(s) if r else "".join(s[::-1]) + d + "".join(e))'] | ['Runtime Error', 'Accepted'] | ['s391016814', 's478228265'] | [3056.0, 18952.0] | [17.0, 338.0] | [214, 448] |
p02756 | u238504302 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nQuery = list(input().split() for _ in range(Q))\n\ncount = 0\nL, R = "", ""\n\nfor i in range(Q):\n if Query[i][0] == "1": count += 1\n else:\n if Query[i][1] == "1":\n if count % 2 == 0: L = Query[i][2] + L\n else: R += Query[i][2]\n else:\n if count % 2 == 0: R += Query[i][2]\n else: L = Query[i][2] + L\n print(L + S + R)\n\nif count % 2 == 0: print(L + S + R)\nelse: print(R[::-1] + S[::-1] + L[::-1])', 'from queue import deque\nS = input()\nQ = int(input())\nQuery = list(input().split() for _ in range(Q))\n\ncount = 0\nL, R = deque(), deque()\n\nfor i in range(Q):\n if Query[i][0] == "1": count += 1\n else:\n if Query[i][1] == "1":\n if count % 2 == 0: L.appendleft(Query[i][2])\n else: R.append(Query[i][2])\n else:\n if count % 2 == 0: R.append(Query[i][2])\n else: L.appendleft(Query[i][2])\nL, R = "".join(L), "".join(R)\nif count % 2 == 0: print(L + S + R)\nelse: print(R[::-1] + S[::-1] + L[::-1])'] | ['Runtime Error', 'Accepted'] | ['s510518693', 's013691154'] | [171376.0, 45844.0] | [589.0, 376.0] | [447, 513] |
p02756 | u239917977 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n from collections import deque\n S = deque(input().split())\n Q = int(input())\n\n q_list = [input().split() for _ in range(Q)]\n\n flag = True\n for q in q_list:\n if len(q) == 1:\n t = q[0]\n else:\n t, f, c = q\n\n if t == \'1\':\n flag = not flag\n else:\n if (f == \'1\') ^ flag:\n S.appendleft(c)\n else:\n S.append(c)\n # print(q)\n # print("".join(S))\n print("".join(S))\n\n\nif __name__ == \'__main__\':\n main()\n', 'def main():\n\n S = input().split()\n s = S\n Q = int(input())\n s_ind = 0\n\n q_list = [input().split() for _ in range(Q)]\n for q in q_list:\n if len(q) == 1:\n t = q[0]\n else:\n t, f, c = q\n\n if t == \'1\' or t == 1:\n front = S[:s_ind]\n end = S[s_ind+1:]\n s_ind = len(S)-s_ind\n end.append(s)\n end.extend(front)\n S = end\n else:\n if f == \'1\' or f == 1:\n S.insert(0, c)\n s_ind += 1\n else:\n S.append(c)\n\n print("".join(S))\n\n\nif __name__ == \'__main__\':\n main()\n', 'def main():\n from collections import deque\n S = deque(input())\n Q = int(input())\n\n q_list = [input().split() for _ in range(Q)]\n\n flag = False\n for q in q_list:\n if len(q) == 1:\n t = q[0]\n else:\n t, f, c = q\n\n if t == \'1\':\n flag = not flag\n else:\n if (f == \'1\') ^ flag:\n S.appendleft(c)\n else:\n S.append(c)\n if flag:\n print("".join(S))\n\n\nif __name__ == \'__main__\':\n main()\n', 'def main():\n from collections import deque\n S = deque(input())\n Q = int(input())\n\n q_list = [input().split() for _ in range(Q)]\n\n flag = False\n for q in q_list:\n if len(q) == 1:\n t = q[0]\n else:\n t, f, c = q\n\n if t == \'1\':\n flag = not flag\n else:\n if (f == \'1\') ^ flag:\n S.appendleft(c)\n else:\n S.append(c)\n if flag:\n S.reverse()\n print("".join(S))\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s619210115', 's758921782', 's800169696', 's462975308'] | [43116.0, 42328.0, 44268.0, 44532.0] | [404.0, 2106.0, 393.0, 420.0] | [554, 653, 517, 533] |
p02756 | u241159583 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = list(input())\nprint(S)\nQ = int(input())\n\nfor _ in range(Q):\n q = list(input())\n if len(q) == 1:\n r = S[0]\n l = S[-1]\n S[0] = l\n S[-1] = r\n else:\n if q[2] == "1": S.insert(0, q[4])\n else: S.append(q[4])\n\nprint("".join(S)) ', 'from collections import deque\nS = deque(input())\nQ = int(input())\nq = [input().split() for _ in range(Q)]\nflag = True\nfor x in q:\n if x[0] == "1":\n if flag: flag = False\n else: flag = True\n else:\n if x[1] == "1":\n if flag: S.appendleft(x[2])\n else: S.append(x[2])\n else:\n if flag: S.append(x[2])\n else: S.appendleft(x[2])\ns = list(S)\nif not flag: s = s[::-1]\nprint("".join(s))'] | ['Wrong Answer', 'Accepted'] | ['s697522557', 's902024903'] | [5616.0, 49060.0] | [2104.0, 357.0] | [246, 454] |
p02756 | u243714267 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\n\nflag_swap = False\nfor i in range(q):\n query = list(input().split())\n if query[0] == "1":\n flag_swap = not flag_swap\n else:\n if (query[1] == "1" and not flag_swap) or (query[1] == "2" and flag_swap):\n s = query[2] + s\n else:\n s += query[2]\n\nidx = range(len(s))\nif flag_swap:\n idx = reversed(idx)\nfor i in idx:\n print(s[i], end="")\n \n \n ', 's = input()\nq = int(input())\nleft = ""\nright = ""\nflag_swap = False\nfor i in range(q):\n query = list(input().split())\n if query[0] == "1":\n flag_swap = not flag_swap\n else:\n if (query[1] == "1" and not flag_swap) or (query[1] == "2" and flag_swap):\n left += query[2]\n else:\n right += query[2]\n\nif flag_swap:\n print(right[::-1]+s[::-1]+left)\nelse:\n print(left[::-1]+s+right)\n \n \n '] | ['Time Limit Exceeded', 'Accepted'] | ['s404659593', 's808637764'] | [4952.0, 4468.0] | [2104.0, 507.0] | [400, 414] |
p02756 | u244416763 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = str(input())\nq = int(input())\nquery = [0 for _ in range(q)]\nw = True\nfor i in range(q):\n query[i] = list(map(str,input().split()))\nfor i in range(q):\n if(query[i][0] == "1"):\n w = not(w)\n else:\n mem = query[i][2]\n if(query[i][1] == "1"):\n if(w):\n s = s + mem\n else:\n s = mem + s\n else:\n if(w):\n s = mem + s\n else:\n s = s + mem\nprint(s)', 'from collections import deque\ns = str(input())\nq = int(input())\ns = deque(s)\nquery = []\nw = True\nfor i in range(q):\n query = list(map(str,input().split()))\n if(query[0] == "1"):\n w = not(w)\n else:\n mem = query[2]\n if(query[1] == "1"):\n if(w):\n s.appendleft(mem)\n else:\n s.append(mem)\n else:\n if(w):\n s.append(mem)\n else:\n s.appendleft(mem)\nif(w):\n print("".join(s))\nelse:\n s.reverse()\n print("".join(s))'] | ['Wrong Answer', 'Accepted'] | ['s067452904', 's293737051'] | [40108.0, 8692.0] | [2106.0, 647.0] | [480, 553] |
p02756 | u250583425 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n S = input()\n Q = int(input())\n\n reverse = False\n header = []\n footer = []\n for _ in range(Q):\n query = input()\n if query[0] == \'1\':\n reverse = not reverse\n else:\n _, f, c = query.split()\n if reverse:\n if f == \'1\':\n footer = [c] + footer\n else:\n header.append(c)\n else:\n if f == \'1\':\n header.append(c)\n else:\n footer = [c] + footer\n if reverse:\n print("".join(footer + list(S)[::-1] + header))\n else:\n print("".join(header) + S + "".join(footer))\n\nif __name__ == \'__main__\':\n main()', 'import sys\ndef input(): return sys.stdin.readline().rstrip()\n\ndef main():\n S = input()\n Q = int(input())\n\n reverse = False\n header = [\'\'] * Q\n footer = [\'\'] * Q\n for i in range(Q):\n query = input()\n if query[0] == \'1\':\n reverse = not reverse\n else:\n _, f, c = query.split()\n isHead = f == \'1\'\n if reverse:\n isHead = not isHead\n if isHead:\n header[i] = c\n else:\n footer[i] = c\n\n if reverse:\n print("".join(footer[::-1] + list(S)[::-1] + header))\n else:\n print("".join(header[::-1]) + S + "".join(footer))\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s725060845', 's673221866'] | [5220.0, 12600.0] | [2104.0, 180.0] | [798, 713] |
p02756 | u250828304 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\n\ns = input()\nd1 = deque()\nd2 = deque()\nd3 = deque()\nnum = 0\nfor i in s:\n d2.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1:\n if len(d2) != 1:\n num += 1\n else:\n f = int(data[1])\n c = data[2]\n if f == 1:\n d1.append(c)\n else:\n d3.append(c)\nif num % 2 == 1:\n d1.reverse()\n d2.reverse()\n d3.reverse()\ns1 = list(d1)\ns1 = "".join(s1)\ns2 = list(d2)\ns2 = "".join(s2)\ns3 = list(d3)\ns3 = "".join(s3)\n\n\nprint(s3+s2+s1)', 'from collections import deque\n\ns = input()\nd = deque()\nnum = 0\nfor i in s:\n d.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1 :\n num += 1\n else:\n if num %2 == 1:\n d.reverse()\n num = 0 \n f = int(data[1])\n c = data[2]\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\n\ns = list(d)\ns = "".join(s)\n\n\n\nprint(s)', 'from collections import deque\n\ns = input()\nd = deque()\nd.append(s)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1:\n if len(s) != 1:\n tmp1 = d.pop()\n tmp2 = d.popleft()\n d.appendleft(tmp2)\n d.append(tmp1)\n else:\n f = int(data[1])\n c = data[2]\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\n \ns = list(d)\ns = "".join(s)\nprint(s)', 'from collections import deque\n\ns = input()\nd = deque()\nfor i in s:\n d.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1:\n if len(d) != 1:\n tmp1 = d.pop()\n tmp2 = d.popleft()\n d.appendleft(tmp1)\n d.append(tmp2)\n else:\n f = int(data[1])\n c = data[2]\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\nd.reverse()\ns = list(d)\ns = "".join(s)\nprint(s)', 'from collections import deque\n\ns = input()\nd = deque()\nnum = 0\nfor i in s:\n d.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1:\n tmp = d.pop()\n d[len(d)-1] = d[0]\n d[0] = tmp\n else:\n f = int(data[1])\n c = data[2]\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\n\ns = list(d)\ns = "".join(s)\n\n\n\nprint(s)', 'from collections import deque\n\ns = input()\nd = deque()\nfor i in s:\n d.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1:\n if len(d) != 1:\n tmp1 = d.pop()\n tmp2 = d.popleft()\n d.appendleft(tmp1)\n d.append(tmp2)\n else:\n f = int(data[1])\n c = data[2]\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\n \ns = list(d)\ns = "".join(s)\nprint(s)', 'from collections import deque\n\ns = input()\nd = deque()\nheader = 1\nfor i in s:\n d.append(i)\nq = int(input())\nfor i in range(q):\n data = input().split()\n if len(data) == 1 :\n header *= -1\n else:\n f = int(data[1])\n c = data[2]\n if header == 1:\n if f == 1:\n d.appendleft(c)\n else:\n d.append(c)\n else:\n if f == 1:\n d.append(c)\n else:\n d.appendleft(c)\n \nif header == -1:\n d.reverse()\n\ns = list(d)\ns = "".join(s)\n\n\n\nprint(s)'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s039879922', 's264546020', 's402330228', 's578981346', 's739032336', 's785965265', 's626890049'] | [7516.0, 8692.0, 6900.0, 8556.0, 8564.0, 4980.0, 8564.0] | [499.0, 2104.0, 507.0, 506.0, 511.0, 378.0, 499.0] | [611, 493, 537, 552, 472, 477, 650] |
p02756 | u252828980 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = list(input())\nn = int(input())\nimport numpy as np\n\ns = np.array(s)\n\nL = []\nfor i in range(n):\n flag = False\n L = (list(map(str,input())))\n #print(L)\n if len(L) >1:\n if int(L[2]) == 1:\n if flag:\n s = np.append(s,L[4])\n else:\n s = np.append(L[4],s)\n elif int(L[2]) == 2:\n if flag:\n s = np.append(L[4],s)\n else:\n s = np.append(s,L[4])\n \n elif len(L) ==1:\n flag = True\nif flag:\n s = s[::-1]\nprint("".join(s))', 'rom collections import deque\ns = input()\nn = int(input())\ns = deque(s)\ncnt = 0\ndef ap(s,a,b):\n if flag ==True:\n if a == "1":\n s.appendleft(b)\n elif a == "2":\n s.append(b)\n if flag == False:\n if a == "1": \n s.append(b)\n elif a == "2":\n s.appendleft(b)\nflag = True\nfor i in range(n):\n L = list(input())\n if L[0] == "1":\n flag = False\n cnt +=1\n elif L[0] == "2":\n ap(s,L[2],L[4])\n flag = True\n#print(flag,cnt,s)\nif cnt %2 == 1:\n s.reverse()\nprint("".join(s))', 's = list(input())\nn = int(input())\nimport numpy as np\n\ns = np.array(s)\n\nL = []\nfor i in range(n):\n L = (list(map(str,input())))\n #print(L)\n if len(L) >1:\n if int(L[2]) == 1:\n #print(s)\n s = np.append(L[4],s)\n elif int(L[2]) == 2:\n s = np.append(s,L[4])\n \n elif len(L) ==1:\n s = np.rot90(s, 2)\n \nprint("".join(s))', 'from collections import deque\ns = input()\ns = deque(s)\nn = int(input())\ncnt = False\nfor i in range(n):\n L = input()\n if len(L) == 1:\n cnt ^=1 \n else:\n a,b,c = L.split()\n if cnt:\n if b == "1":\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if b == "1":\n s.appendleft(c)\n else:\n s.append(c)\nif cnt:\n s = reversed(s)\n print("".join(s))\nelse:\n print("".join(s))'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s024109647', 's027495773', 's759245024', 's366833893'] | [18904.0, 2940.0, 14044.0, 8436.0] | [2108.0, 17.0, 2108.0, 412.0] | [554, 573, 388, 428] |
p02756 | u254221913 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\nque = [0] * q\nt = []\nf = []\nc = []\nfor i in range(q):\n que[i] = list(map(str,input().split()))\n if(len(que[i])==3):\n t.append(que[i][0])\n f.append(que[i][1])\n c.append(que[i][2])\n else:\n t.append(que[i][0])\ncount = 0\nfor i in range(q):\n if t[i] == '1':\n s = s[::-1]\n print(t[i-1])\n else:\n if f[count] == '1':\n s = c[count] + s\n count += 1\n else:\n s += c[count]\n count += 1\nprint(s)", 'from collections import deque\ns = input()\nsque = deque(s)\nq = int(input())\nque = [0] * q\nflg = False\nfor i in range(q):\n que[i] = (list(map(str,input().split())))\n if(len(que[i])==3):\n if que[i][1] == \'1\':\n if flg:\n sque.append(que[i][2])\n else:\n sque.appendleft(que[i][2])\n else:\n if flg:\n sque.appendleft(que[i][2])\n else:\n sque.append(que[i][2])\n else:\n if flg:\n flg = False\n else:\n flg = True\nif flg:\n sque.reverse()\n print("".join(list(sque)))\nelse:\n print("".join(list(sque)))'] | ['Wrong Answer', 'Accepted'] | ['s275184555', 's358044443'] | [45344.0, 44652.0] | [2106.0, 758.0] | [525, 654] |
p02756 | u255821449 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['# -*- coding: utf-8 -*-\nfrom collenctions import deque\n\nS = input()\nQ = int(input())\n\nquerys = []\nop1_cnt = 0\nop2_cnt = 0\nprefix = deque()\nsuffix = deque()\nfor i in range(Q):\n query = input()\n if len(query) == 1:\n op1_cnt += 1\n\n if op2_cnt != 0:\n prefix.extend(S)\n prefix.extend(suffix)\n S = \'\'.join(prefix)\n prefix.clear()\n suffix.clear()\n op2_cnt = 0\n\n else:\n op2_cnt += 1\n\n if op1_cnt % 2 != 0:\n S = S[::-1]\n\n op1_cnt = 0\n\n t, F, C = query.split()\n if F == "1":\n prefix.appendleft(C)\n else:\n suffix.append(C)\n\nif op1_cnt % 2 != 0:\n S = S[::-1]\n\nif op2_cnt != 0:\n prefix.extend(S)\n prefix.extend(suffix)\n S = \'\'.join(prefix)\n\n\nprint(S)\n', '# -*- coding: utf-8 -*-\nS = input()\nQ = int(input())\n\nreverse = 0\nhead = []\ntail = []\nfor i in range(Q):\n query = input()\n if len(query) == 1:\n reverse = (reverse + 1) % 2\n\n else:\n t, F, C = query.split()\n if reverse == 0:\n if F == "1":\n head.append(C)\n else:\n tail.append(C)\n else:\n if F == "1":\n tail.append(C)\n else:\n head.append(C)\n\nif reverse == 0:\n S = \'\'.join(head[::-1] + list(S) + tail)\nelse:\n S = \'\'.join(tail[::-1] + list(S[::-1]) + head)\n\n\nprint(S)\n'] | ['Runtime Error', 'Accepted'] | ['s506408334', 's385470942'] | [3064.0, 9284.0] | [17.0, 413.0] | [814, 608] |
p02756 | u257265865 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S=input()\nQ=int(input())\nl=list(input().split() for i in range(Q))\nfor j in l:\n if j[0]=="1":\n S=S[::-1]\n else:\n if j[1]=="1":\n S=S+j[2]\n else:\n S=j[2]+S\n\nprint(S)\n ', 'from collections import deque\nS=deque(list(input()))\nQ=int(input())\nl=list(input().split() for i in range(Q))\na=0\nfor j in l:\n if j[0]=="1":\n a+=1\n else:\n if j[1]=="1":\n if a %2==0:\n S.appendleft(j[2])\n else:\n S.append(j[2])\n else:\n if a %2==1:\n S.appendleft(j[2])\n else:\n S.append(j[2])\n \nif a%2==0:\n print("".join(S))\nelse:\n S.reverse()\n print("".join(S))\n '] | ['Wrong Answer', 'Accepted'] | ['s092530313', 's663560682'] | [41684.0, 44516.0] | [2107.0, 467.0] | [191, 465] |
p02756 | u260216890 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def solve2(s):\n ans = 0\n for i, c in enumerate(s): \n if c in '02468':\n ans += i + 1 \n \n \n \n return ans\n\n\ndef solve5(s): \n ans = 0\n for i, c in enumerate(s):\n if c in '05':\n ans += i + 1\n return ans\n\n\ndef solve_other(s, p):\n ans = 0\n last_mod=0\n mods = [0]*p\n mods[0] = 1 \n digit = 1\n for i in range(n-1,-1,-1): \n last_mod = (last_mod + int(s[i])*digit)%p \n ans += mods[last_mod] \n mods[last_mod] += 1 \n digit *=10 \n return ans\n\n\nn, p = list(map(int, input().split()))\ns = input()\nif p == 2:\n print(solve2(s))\nelif p == 5:\n print(solve5(s))\nelse:\n print(solve_other(s, p))", "from collections import deque\ns=deque(list(input()))\nq=int(input())\ndirection=0 \n\nfor i in range(q):\n query=input()\n if query[0]=='1':\n direction=direction^1\n elif query[0]=='2':\n i,f,c=query.split()\n if f=='1' and direction==0:\n s.appendleft(c)\n elif f=='1' and direction==1:\n s.append(c)\n elif f=='2' and direction==0:\n s.append(c)\n elif f=='2' and direction==1:\n s.appendleft(c)\n\n\nif direction==0:\n print(''.join(s))\nelse:\n s=''.join(s)\n s=s[::-1]\n print(s)\n"] | ['Runtime Error', 'Accepted'] | ['s122476251', 's277206760'] | [3316.0, 8676.0] | [19.0, 440.0] | [1368, 580] |
p02756 | u266113953 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\nreverse = False\nfront = ""\nend = ""\n\nfor i in range(Q):\n inp = input()\n if inp[0] == "1":\n reverse = ~reverse\n else:\n _, F, C = inp.split()\n if (F == "1" and reverse == False) or (F == "2" and reverse == True):\n front = front+C\n else:\n end = end+C\n\nif reverse:\n print(end[::-1]+S[::-1]+front)\nelse:\n print(front[::-1]+S+end)\n', ' S = input()\n Q = int(input())\n reverse = False\n front = ""\n end = S\n \n for i in range(Q):\n inp = input()\n if inp[0] == "1":\n reverse = ~reverse\n else:\n _, F, C = inp.split()\n if (F == "1") ^ reverse:\n front =front+C\n else:\n end = end+C\n \n \n if reverse:\n print(end[::-1]+front)\n else:\n print(front[::-1]+end)', 'S = input()\nQ = int(input())\nreverse = False\nfront = ""\nend = ""\n\nfor i in range(Q):\n print(end[::-1]+S[::-1]+front)\n inp = input()\n if inp[0] == "1":\n reverse = ~reverse\n else:\n _, F, C = inp.split()\n if (F == "1" and reverse == False) or (F == "2" and reverse == True):\n front = front+C\n else:\n end = end+C\n\nif reverse:\n print(end[::-1]+S[::-1]+front)\nelse:\n print(front[::-1]+S+end)\n', 'S = input()\nQ = int(input())\nreverse = False\nfront = ""\nend = ""\n \nfor i in range(Q):\n inp = input()\n if inp[0] == "1":\n reverse = not reverse\n else:\n _, F, C = inp.split()\n if (F == "1") ^ reverse:\n front = front+C\n else:\n end = end+C\n \nif reverse:\n print(end[::-1]+S[::-1]+front)\nelse:\n print(front[::-1]+S+end)'] | ['Wrong Answer', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s209027871', 's312068290', 's442599945', 's983354352'] | [4396.0, 2940.0, 134524.0, 4468.0] | [466.0, 17.0, 363.0, 469.0] | [419, 453, 454, 378] |
p02756 | u268554510 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def main():\n S = input()\n Q = int(input())\n import sys\n que = [list(sys.stdin.readline().split()) for _ in range(Q)]\n judge = False\n for l in que:\n if int(l[0])==1:\n if judge:\n judge = False\n else:\n judge = True\n\n elif int(l[0])==2:\n f,c = int(l[1]),l[2]\n if judge:\n S=S[::-1]\n print(S)\n \nmain()\n', 'def main():\n S = input()\n Q = int(input())\n import sys\n que = [list(sys.stdin.readline().split()) for _ in range(Q)]\n judge = False\n for l in que:\n if int(l[0])==1:\n if judge:\n judge = False\n else:\n judge = True\n\n elif int(l[0])==2:\n f,c = int(l[1]),l[2]\n if judge:\n if f==1:\n f=2\n elif f==2:\n f=1\n if judge:\n S=S[::-1]\n print(S)\n \nmain()', "def main():\n S = input()\n Q = int(input())\n import sys\n que = [list(sys.stdin.readline().split()) for _ in range(Q)]\n judge = False\n for l in que:\n if int(l[0])==1:\n if judge:\n judge = False\n else:\n judge = True\n\n elif int(l[0])==2:\n f,c = int(l[1]),l[2]\n if judge:\n if f==1:\n f=2\n elif f==2:\n f=1\n if f==2:\n S = ''.join([S,c])\n\n if judge:\n S=S[::-1]\n print(S)\n \nmain()", "def main():\n S = input()\n Q = int(input())\n import sys\n que = [list(sys.stdin.readline().split()) for _ in range(Q)]\n pre=''\n post=''\n judge = False\n for l in que:\n if int(l[0])==1:\n if judge:\n judge = False\n else:\n judge = True\n\n elif int(l[0])==2:\n f,c = int(l[1]),l[2]\n if judge:\n if f==1:\n f=2\n elif f==2:\n f=1\n if f==1:\n pre = ''.join([pre,c])\n elif f==2:\n post = ''.join([post,c])\n\n pre = pre[::-1]\n S = pre+S+post\n if judge:\n S=S[::-1]\n print(S)\n \nmain()"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s456131753', 's707122144', 's870016742', 's636434030'] | [29940.0, 30068.0, 31992.0, 32196.0] | [304.0, 304.0, 1405.0, 1451.0] | [343, 422, 465, 573] |
p02756 | u274635633 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s=input()\nn=int(input())\nq=[list(map(int,input().split())) for i in range(n)]\natama=0\nx=0\nfor i in range(n):\n if q[i][0]==2:\n x+=1\n\noshiri=len(s)+x-1\nans=[None]*(s+x)\nx=0\nfor i in range(n)[::-1]:\n if q[i][0]==1:\n x+=1\n else:\n if (q[i][1]+x)%2==0:\n ans[oshiri]=q[i][2]\n oshiri-=1\n else:\n ans[atama]=q[i][2]\n atama+=1\n\nif x%2==1:\n s=s[::-1]\n\nfor i in range(len(s)):\n ans[i+atama]=s[i]\n\nprint(ans,sep='')", "s=input()\nn=int(input())\nq=[list(map(str,input().split())) for i in range(n)]\natama=0\nx=0\nfor i in range(n):\n if q[i][0]=='2':\n x+=1\n\noshiri=len(s)+x-1\nans=[]\nfor i in range(len(s)+x):\n ans.append('x')\nx=0\nfor i in range(n)[::-1]:\n if q[i][0]=='1':\n x+=1\n else:\n if (int(q[i][1])+x)%2==0:\n ans[oshiri]=q[i][2]\n oshiri-=1\n else:\n ans[atama]=q[i][2]\n atama+=1\n\nif x%2==1:\n s=s[::-1]\n\nfor i in range(len(s)):\n ans[i+atama]=s[i]\n\nanswer=ans[0]\nfor i in range(1,len(ans)):\n answer+=ans[i]\n \nprint(answer)"] | ['Runtime Error', 'Accepted'] | ['s953746633', 's185472224'] | [3316.0, 42544.0] | [18.0, 874.0] | [438, 545] |
p02756 | u276894499 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import math\nS = input()\nQ = int(input())\nfor n in range(Q):\n T,F,C = input()\n if T == "1":\n S = S[::-1]\n else:\n if F == "1":\n S = C + S\n else:\n S = S + C\nprint(S)\n', 'from collections import deque\n\nS = deque(input())\nQ = int(input())\nflg = True\nfor _ in range(Q):\n query = input()\n if query[0] == "1":\n flg = not flg\n else:\n _,F,C = query.split()\n if (F == "1" and flg) or (F == "2" and not flg):\n S.appendleft(C)\n else:\n S.append(C)\nif not flg:\n S.reverse()\n\nprint(\'\'.join(S))\n'] | ['Runtime Error', 'Accepted'] | ['s695087167', 's796898868'] | [3188.0, 8820.0] | [18.0, 414.0] | [215, 373] |
p02756 | u279266699 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\nfrom collections import deque\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ns = readline().rstrip()\nq = readline()\nqueries = readlines()\ns = deque(s)\ntot_1 = 0\nfor i in queries:\n if i[0] == \'1\':\n tot_1 += 1\n continue\n c = i[4]\n if (tot_1 + int(i[2])) % 2 == 0:\n s.append(c)\n else:\n s.appendleft(c)\nans = "".join(queue) if tot_1 % 2 == 0 else "".join(reversed(queue))\nprint(ans)', "import sys\n\nreadline = sys.stdin.readline\nreadlines = sys.stdin.readlines\n\ns = readline().rstrip()\nqueries = readlines()\ntot_1 = 0\nfor i in queries:\n if i[0] == '1':\n tot_1 += 1\n else:\n if (tot_1 + int(i[2])) % 2 == 0:\n s = s + i[4]\n else:\n s = i[4] + s\nif tot_1 % 2 == 1:\n s = s[::-1]\nprint(s)", "from collections import deque\n\n\ndef order_manegement():\n while True:\n yield 1\n yield 0\n\n\ndef main():\n s = input()\n q = int(input())\n s = deque(s)\n gen = order_manegement()\n state = 0\n for i in range(q):\n order = list(input().split())\n if order[0] == '1':\n state = next(gen)\n elif order[0] == '2':\n if (state + int(order[1])) % 2 == 0:\n s.append(order[2])\n else:\n s.appendleft(order[2])\n s = list(s)\n if state == 1:\n s = s[::-1]\n\n print(''.join(s))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s300356530', 's814364089', 's458896075'] | [18408.0, 18344.0, 13896.0] | [159.0, 1996.0, 318.0] | [446, 346, 623] |
p02756 | u281610856 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\nimport sys\ninput = sys.stdin.readline\n\ns = list(input())\nq = int(input())\nans = deque(s)\nfor i in range(q):\n arr = list(map(str, input().split()))\n if arr[0] == '1':\n ans.reverse()\n else:\n if arr[1] == '1':\n ans.appendleft(arr[2])\n else:\n ans.append(arr[2])\nprint(*ans, sep='')\n", "from collections import deque\n\n\ns = list(input())\nq = int(input())\nans = deque(s)\ncnt = 0\nfor i in range(q):\n arr = list(map(str, input().split()))\n if arr[0] == '1':\n cnt += 1\n cnt %= 2\n else:\n if (arr[1] == '1' and cnt == 0) or (arr[1] == '2' and cnt == 1):\n ans.appendleft(arr[2])\n else:\n ans.append(arr[2])\nif cnt == 0:\n print(*ans, sep='')\nelse:\n ans.reverse()\n print(*ans, sep='')\n\n"] | ['Wrong Answer', 'Accepted'] | ['s939146532', 's925910379'] | [13160.0, 13168.0] | [2104.0, 737.0] | [360, 456] |
p02756 | u281796054 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s=input()\nn=int(input())\nfront=""\nback=""\nreverse=False\n\nfor i in range(n):\n t=input().split()\n if t[0]=="1":\n reverse=not reverse\n else:\n if (t[1]=="1")and not reverse:\n front=front+t[2]\n elif (t[1]=="2")and reverse:\n else:\n back=back+t[2]\nif reverse:\n print(back[::-1]+s+front)\nelse:\n print(front[::-1]+s+back)\n', 's=input()\nn=int(input())\nfront=""\nback=s\nreverse=False\n\nfor i in range(n):\n t=input().split()\n if t[0]=="1":\n reverse=not reverse\n else:\n if (t[1]=="1")^reverse:\n front=front+t[2]\n else:\n back=back+t[2]\nif reverse:\n print(back[::-1]+front)\nelse:\n print(front[::-1]+back)\n'] | ['Runtime Error', 'Accepted'] | ['s177260097', 's941958706'] | [2940.0, 4596.0] | [17.0, 450.0] | [340, 295] |
p02756 | u282265659 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n \ns = input()\nq = int(input())\nans = deque(s)\ncnt = 0\nfor i in range(q):\n f = [i for i in input().split()]\n if f[0] == '1':\n cnt += 1\n else:\n if f[1] == '1':\n if cnt % 2 == 0:\n ans.appendleft(f[2])\n else:", "from collections import deque\n \ns = input()\nq = int(input())\nans = deque(s)\ncnt = 0\nfor i in range(q):\n f = [i for i in input().split()]\n if f[0] == '1':\n cnt += 1\n else:\n if f[1] == '1':\n if cnt % 2 == 0:\n ans.appendleft(f[2])\n else:\n ans.append(f[2])\n else:\n if cnt % 2 == 0:\n ans.append(f[2])\n else:\n ans.appendleft(f[2])\nif cnt % 2 != 0:\n ans.reverse()\nprint(''.join(map(str,ans)))"] | ['Runtime Error', 'Accepted'] | ['s653217070', 's224684459'] | [2940.0, 8688.0] | [17.0, 554.0] | [294, 522] |
p02756 | u283929013 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\n\ndef rev(s):\n re = ""\n for k in range(len(s)):\n re = re + s[len(s) - 1 - k]\n return re\n\nflag = False\ncount = 0\n\nfor i in range(Q):\n k = input()\n if k == "1":\n if i == Q -1:\n if count % 2 == 0:\n print(count)\n S = rev(S)\n else:\n flag = True\n count += 1\n else:\n if flag:\n if count % 2 == 1:\n S = rev(S)\n flag = False\n count = 0\n if k[2] == "1":\n S = k[4] + S\n else:\n S = S + k[4]\n\nprint(S)', 'S = input()\nQ = int(input())\n \nA = ""\nB = ""\ncount = 0\n\nQue = []\nope = []\n\ndef rev(s):\n re = ""\n for i in range(len(s)):\n re = re + s[len(s) - 1 - i]\n return re\n \nfor i in range(Q):\n k = input()\n if k == "1":\n count += 1\n Que.append("1")\n ope.append("0")\n else:\n Que.append("2")\n ope.append([k[2],k[4]])\n \ncou = 0\n \nif count % 2 == 0:\n for i in range(Q):\n if Que[i] == "1":\n cou += 1\n else:\n if (int(ope[i][0]) + cou) % 2 == 1:\n A = ope[i][1] + A\n else:\n B = B + ope[i][1]\nelse:\n for i in range(Q):\n if Que[i] == "1":\n cou += 1\n else:\n if (int(ope[i][0]) + cou) % 2 == 1:\n A = A + ope[i][1]\n else:\n B = ope[i][1] + B\n \nif count % 2 == 0:\n S = A + S + B\nelse:\n S = rev(S)\n S = B + S + A\n \nprint(S)'] | ['Wrong Answer', 'Accepted'] | ['s955258036', 's422105426'] | [3856.0, 26448.0] | [2103.0, 1528.0] | [608, 925] |
p02756 | u287182213 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["#for _ in range(int(input())):\ns = input()\nq = int(input())\nb=0\nfor _ in range(q):\n qi = input().split(' ')\n print(len(qi))\n if(len(qi)==1):\n b=b^1\n else:\n fi = int(qi[1])\n if(fi==1):\n if(b==0):\n s=qi[2]+s\n else:\n s=s+qi[2]\n elif(fi==2):\n if(b==0):\n s=s+qi[2]\n else:\n s=qi[2]+s\nif(b==1):\n s=s[::-1]\n\nprint(s)\n \n \n \n ", '#for _ in range(int(input())):\ns = input()\nq = int(input())\nb=0\nf,l="",""\nfor _ in range(q):\n qi = input().split(\' \')\n #print(len(qi))\n if(len(qi)==1):\n b=b^1\n else:\n fi = int(qi[1])\n if(fi==1):\n if(b==0):\n f=f+qi[2]\n else:\n l=l+qi[2]\n elif(fi==2):\n if(b==0):\n l=l+qi[2]\n else:\n f=f+qi[2]\ns = f[::-1]+s+l\nif(b==1):\n s=s[::-1]\n\nprint(s)\n \n \n \n '] | ['Wrong Answer', 'Accepted'] | ['s945984790', 's490913752'] | [4104.0, 4468.0] | [2108.0, 528.0] | [483, 510] |
p02756 | u290187182 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["if __name__ == '__main__':\n s = input()\n q = int(input())\n ans = s\n rev_count = 0\n leftList = []\n rightList =[]\n alist =[]\n\n for i in range(q):\n a = [i for i in input().split()]\n alist.append(a)\n if len(a) == 1:\n rev_count = rev_count +1\n\n if rev_count % 2 ==1:\n ans = ans[::-1]\n\n for i in alist:\n if len(i) == 1:\n rev_count = rev_count -1\n else:\n if int(i[1]) == 1:\n if rev_count % 2 == 1:\n rightList.append(i[2])\n else:\n leftList.append(i[2])\n\n else:\n if rev_count % 2 == 1:\n leftList.append(i[2])\n else:\n rightList.append(i[2])\n\n ans = ''.join(leftList)+ ans+''.join(rightList)\n\n print(ans)\n", '\nif __name__ == \'__main__\':\n s = input()\n q = int(input())\n ans = s\n rev_count = 0\n alist =[]\n anslist = []\n\n for i in range(q):\n a = [i for i in input().split()]\n alist.append(a)\n if len(a) == 1:\n rev_count = rev_count +1\n\n if rev_count % 2 ==1:\n ans = ans[::-1]\n anslist.append(ans)\n\n for i in alist:\n if len(i) == 1:\n rev_count = rev_count -1\n else:\n if int(i[1]) == 1:\n if rev_count % 2 == 1:\n anslist.append(i[2])\n else:\n anslist.insert(0,i[2])\n\n else:\n if rev_count % 2 == 1:\n anslist.insert(0,i[2])\n else:\n anslist.append(i[2])\n\n print("".join(anslist))\n', "if __name__ == '__main__':\n s = input()\n q = int(input())\n ans = s\n rev_count = 0\n leftList = []\n rightList =[]\n alist =[]\n\n for i in range(q):\n a = [i for i in input().split()]\n alist.append(a)\n if len(a) == 1:\n rev_count = rev_count +1\n\n if rev_count % 2 ==1:\n ans = ans[::-1]\n\n for i in alist:\n if len(i) == 3:\n rev_count = rev_count -1\n else:\n if int(i[1]) == 1:\n if rev_count % 2 == 1:\n rightList.append(i[2])\n else:\n leftList.append(i[2])\n\n else:\n if rev_count % 2 == 1:\n leftList.append(i[2])\n else:\n rightList.append(i[2])\n\n ans = leftList.join + ans+rightList.join\n\n print(ans)\n\n", "from collections import deque\n\nif __name__ == '__main__':\n s = input()\n q = int(input())\n ans = s\n rev_count = 0\n leftList = deque()\n rightList =[]\n alist =[]\n\n for i in range(q):\n a = [i for i in input().split()]\n alist.append(a)\n if len(a) == 1:\n rev_count = rev_count +1\n\n if rev_count % 2 ==1:\n ans = ans[::-1]\n\n for i in alist:\n if len(i) == 1:\n rev_count = rev_count -1\n else:\n if int(i[1]) == 1:\n if rev_count % 2 == 1:\n rightList.append(i[2])\n else:\n leftList.appendleft(i[2])\n\n else:\n if rev_count % 2 == 1:\n leftList.appendleft(i[2])\n else:\n rightList.append(i[2])\n\n ans = ''.join(leftList)+ ans+''.join(rightList)\n\n print(ans)\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s114260194', 's908935351', 's978918918', 's865384967'] | [29316.0, 29684.0, 26740.0, 30068.0] | [627.0, 2105.0, 540.0, 639.0] | [852, 820, 846, 897] |
p02756 | u296150111 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\nimport sys\ninput=sys.stdin.readline\nmoji=deque([])\ns=input().rstrip()\nfor i in range(len(s)):\n\tmoji.append(ord(s[i]))\nq=int(input())\nrev=0\nfor _ in range(q):\n\tqw=input().split()\n\tif qw[0]=="1":\n\t\trev+=1\n\telse:\n\t\tf=qw[1]\n\t\tc=qw[2]\n\t\tif f=="1":\n\t\t\tif rev%2==0:\n\t\t\t\tmoji.appendleft(ord(c))\n\t\t\telse:\n\t\t\t\tmoji.append(ord(c))\n\t\telse:\n\t\t\tif rev%2==0:\n\t\t\t\tmoji.append(ord(c))\n\t\t\telse:\n\t\t\t\tmoji.appendleft(ord(c))\nans=""\nalph="abcdefghijklmnopqrstuvwxyz"\n\n\nif rev%2==0:\n\tprint(ans)\nelse:\n\tprint(ans[::-1])\n', 'from collections import deque\nimport sys\ninput=sys.stdin.readline\ns=deque([input().rstrip()])\nq=int(input())\nrev=0\nfor _ in range(q):\n\tqw=input().split()\n\tif qw[0]=="1":\n\t\trev+=1\n\telse:\n\t\tf=qw[1]\n\t\tc=qw[2]\n\t\tif f=="1":\n\t\t\tif rev%2==0:\n\t\t\t\ts.appendleft(c)\n\t\t\telse:\n\t\t\t\ts.append(c)\n\t\telse:\n\t\t\tif rev%2==0:\n\t\t\t\ts.append(c)\n\t\t\telse:\n\t\t\t\ts.appendleft(c)\nans=""\nfor x in s:\n\tans+=x\nif rev%2==0:\n\tprint(ans)\nelse:\n\tprint(ans[::-1])\n\n'] | ['Wrong Answer', 'Accepted'] | ['s163411054', 's587293379'] | [5876.0, 6184.0] | [197.0, 205.0] | [579, 426] |
p02756 | u299791633 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\nquery = []\nlead = \'\'\nend = \'\'\ninversion_flg = False\n\nfor j in range(q):\n i = input().split()\n if i[0] == "1":\n if inversion_flg:\n inversion_flg = False \n else:\n inversion_flg = True\n else:\n \n if inversion_flg:\n if i[1] == "1":\n i[1] = 2\n else:\n i[1] = 1\n if i[1] == "1":\n lead+=i[2]\n else:\n end+=i[2]\n inversion_flg = False\n\nlead = lead[::-1]\ns = lead+s+end\nif inversion_flg:\n s = s[::-1]\nprint(s)', 's = input()\nq = int(input())\nlead = \'\'\nend = \'\'\ninversion_flg = -1\n\nfor j in range(q):\n query = input().split()\n if query[0] == "1":\n inversion_flg *= -1\n else:\n if inversion_flg == 1:\n if query[1] == "1":\n query[1] = "2"\n else:\n query[1] = "1"\n if query[1] == "1":\n lead += query[2]\n else:\n end += query[2]\n\nlead = lead[::-1]\ns = lead + s + end\nif inversion_flg == 1:\n s = s[::-1]\nprint(s)\n'] | ['Wrong Answer', 'Accepted'] | ['s581914472', 's145879874'] | [4340.0, 4388.0] | [477.0, 466.0] | [597, 505] |
p02756 | u301624971 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['\nS=input()\nQ=int(input())\nlis=[]\nfor _ in range(Q):\n lis.append(input().split())\nans=S\ncnt=0\nli=[[\'2\',\'1\',"a"] for i in range(2*100000)]\nfor i in li:\n if(int(i[0]) == 1):\n cnt= (cnt+1) % 2\n elif((cnt== 0 and i[1]==\'1\') or (cnt == 1 and i[1]==\'2\')):\n ans= i[2] + ans\n else:\n ans+=i[2]\n\nprint(ans[::-1]) if(cnt % 2 == 1) else print(ans) ', 'from collections import deque\ndef myAnswer(S:deque,Q:int,querys:list) -> str:\n setF = {1,2}\n reverse = False\n for query in querys:\n command = int(query[0])\n if(command == 1):\n reverse = not reverse\n else:\n F = int(query[1])\n C = query[2]\n if(reverse):\n F = set(setF - {F}).pop()\n S.appendleft(C) if(F == 1) else S.append(C)\n\n if(reverse):S.reverse()\n return "".join(S)\n\ndef modelAnswer():\n return\ndef main():\n S = deque(input())\n Q = int(input())\n querys = [list(map(str,input().split())) for _ in range(Q)]\n print(myAnswer(S,Q,querys))\n\n\n\nif __name__ == \'__main__\':\n main()'] | ['Wrong Answer', 'Accepted'] | ['s574299087', 's001174249'] | [62148.0, 44660.0] | [2107.0, 698.0] | [369, 662] |
p02756 | u305366205 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["n = int(input())\n\nif n == 1:\n print('a')\n exit()\n\nans = []\n\n\ndef dfs(s, c):\n for i in range(ord('a'), ord(c) + 2):\n now = s + chr(i)\n if len(now) == n:\n ans.append(now)\n elif i > ord(c):\n dfs(now, chr(i))\n else:\n dfs(now, c)\n\n\ndfs('a', 'a')\n\nfor c in ans:\n print(c)\n", "from collections import deque\ns = deque(list(input()))\nq = int(input())\ncnt = 0\nfor _ in range(q):\n fc = input().split()\n if fc[0] == '1':\n cnt += 1\n else:\n if cnt == 1:\n fc[1] = '1' if fc[1] == '2' else '2'\n if fc[1] == '1':\n s.appendleft(fc[2])\n else:\n s.append(fc[2])\n cnt %= 2\nif cnt == 1:\n s.reverse()\nprint(*s, sep='')\n"] | ['Runtime Error', 'Accepted'] | ['s983466349', 's156592973'] | [3188.0, 12256.0] | [18.0, 530.0] | [339, 401] |
p02756 | u306516971 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S = input()\nQ = int(input())\n\na = 0\nfor i in range(Q):\n t = input()\n if t == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n t,f,c = t.split()\n if f == "1":\n if a == 0:\n S = c + S\n else\n S = S + c\n else:\n if a == 0:\n S = S + c\n else:\n S = c + S\n \nif a == 1:\n S = S[::-1]\n \nprint(S)', 'S = input()\nQ = int(input())\n\na = 0\nfor i in range(Q):\n t = input()\n if t == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n t,f,c = t.split()\n if f == "1":\n if a == 0:\n S = c + S\n else\n S = S + c\n else:\n if a == 0:\n S = S + c\n else:\n S = c + S\n \nif a == 1:\n S = S[::-1]\n \nprint(S)', 'from collections import deque\nS = deque(input())\nQ = int(input())\n\na = 0\nfor i in range(Q):\n t = input()\n if t == "1":\n if a == 0:\n a = 1\n else:\n a = 0\n else:\n t,f,c = t.split()\n if f == "1":\n if a == 0:\n S.appendleft(c)\n else:\n S.append(c)\n else:\n if a == 0:\n S.append(c)\n else:\n S.appendleft(c)\n \nif a == 1:\n S = reversed(S)\n \nS = \'\'.join(S)\nprint(S)'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s027611476', 's911185878', 's263803819'] | [2940.0, 2940.0, 8436.0] | [18.0, 17.0, 395.0] | [466, 466, 539] |
p02756 | u307622233 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns = deque(list(input()))\nq = int(input())\n\nrev = True\n\nfor i in range(q):\n q = list(input().split())\n if(int(q[0]) == 1):\n rev = rev ^ True\n else:\n n = int(q[1])\n if((n == 1 and rev) or (n == 2 and not rev)):\n s.appendleft(0, q[2])\n else:\n s.append(q[2])\n\nif not rev:\n s = s[::-1]\n\nprint(''.join(s))\n", "from collections import deque\n\ns = deque(list(input()))\nq = int(input())\n\nrev = True\n\nfor i in range(q):\n q = list(input().split())\n if(int(q[0]) == 1):\n rev = rev ^ True\n else:\n n = int(q[1])\n if((n == 1 and rev) or (n == 2 and not rev)):\n s.appendleft(q[2])\n else:\n s.append(q[2])\n\n\ntxt = ''\nif rev:\n txt = ''.join(s)\nelse:\n while not(not s):\n txt += s.pop()\n\nprint(txt)\n"] | ['Runtime Error', 'Accepted'] | ['s722945639', 's128842165'] | [4852.0, 8420.0] | [24.0, 615.0] | [393, 445] |
p02756 | u308919961 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["#ABC158 D - String Formation\n\nS = str(input())\nQ = int(input())\nprint(S)\nfor i in range(Q):\n q = input().split(' ')\n if(q[0] == '1'):\n S = S[::-1]\n\n else:\n if(q[1] == '1'):\n temp = [q[2]]\n S = q[2] + S\n else:\n S = S + q[2]\n\nprint(S)\n", '#ABC158 D - String Formation\n\nstart = str(input())\nQ = int(input())\nS = "X"\ncnt = 0\nq = []\nfor i in range(Q):\n q.append(input().split(\' \'))\n if(q[i][0] == \'1\'):\n #S = S[::-1]\n cnt += 1\n\ncntq = 0\nfor i in range(Q):\n \n if(q[i][0] == \'1\'):\n #S = S[::-1]\n cntq += 1\n \n else:\n if((q[i][1] == \'1\' and (cnt-cntq)%2 == 0) or(q[i][1] == \'2\' and (cnt-cntq)%2 == 1)):\n S = q[i][2] + S\n else:\n S = S + q[i][2]\n\nif(cnt%2 == 1):\n start = start[::-1]\n\n\n#print(S)\nprint(S.replace("X",start))\n'] | ['Wrong Answer', 'Accepted'] | ['s231078641', 's442186322'] | [3828.0, 40528.0] | [2107.0, 1855.0] | [296, 581] |
p02756 | u312907447 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = str(input())\nQ = int(input())\n\nqs = [input().split() for i in range(Q)]\n\ni = 0\nwhile i < len(qs):\n q = qs[i]\n if q[0] == '1':\n if qs[i+1][0] == '1':\n i += 2\n else:\n S = S[::-1]\n i += 1\n else:\n if q[1] == '1':\n S = q[2] + S\n else:\n S = S + q[2]\n i += 1\n\n\n\nprint(S)", "from collections import deque\n\nS = str(input())\nQ = int(input())\n\nd = deque([S[i] for i in range(len(S))])\n#print(d)\n\nflg = 0\n\nfor i in range(Q):\n query = input()\n if query[0] == '1':\n flg = flg%2 + 1\n else:\n t, f, c = query.split()\n if f == '1':\n if flg % 2 == 0:\n d.appendleft(c)\n else:\n d.append(c)\n else:\n if flg % 2 == 0:\n d.append(c)\n else:\n d.appendleft(c)\nif flg % 2 == 0:\n print(''.join(list(d)))\nelse:\n tmp = ''.join(list(d))\n print(tmp[::-1])"] | ['Runtime Error', 'Accepted'] | ['s910523914', 's440109913'] | [41696.0, 8540.0] | [2106.0, 459.0] | [366, 603] |
p02756 | u317423698 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\nimport collections\nimport itertools\n\n\ndef resolve(in_):\n one = ord(b'1')\n two = ord(b'2')\n # print(f'{one=} {two=}')\n\n S = in_.readline().strip()\n q = collections.deque(S)\n # print(f'{S=} {q=}')\n\n reverse_flag = False\n Q = int(in_.readline())\n for query in itertools.islice(in_, Q):\n T = query[0]\n if T == one:\n reverse_flag ^= True \n \n elif T == two:\n F = query[2]\n C = query[4]\n if (F == one) ^ reverse_flag:\n q.appendleft(C)\n else:\n q.append(C)\n\n return bytes(reversed(q)) if reversed else bytes(q)\n\n\ndef main():\n answer = resolve(sys.stdin.buffer)\n print(answer.decode('ascii'))\n\n\nif __name__ == '__main__':\n main()\n", "import sys\nimport collections\nimport itertools\n\n\ndef resolve(in_):\n one = ord(b'1')\n two = ord(b'2')\n # print(f'{one=} {two=}')\n\n S = in_.readline().strip()\n q = collections.deque(S)\n # print(f'{S=} {q=}')\n\n reverse_flag = False\n Q = int(in_.readline())\n for query in itertools.islice(in_, Q):\n T = query[0]\n if T == one:\n reverse_flag ^= True \n \n elif T == two:\n F = query[2]\n C = query[4]\n if (F == one) ^ reverse_flag:\n q.appendleft(C)\n else:\n q.append(C)\n\n return bytes(reversed(q)) if reverse_flag else bytes(q)\n\n\ndef main():\n answer = resolve(sys.stdin.buffer)\n print(answer.decode('ascii'))\n\n\nif __name__ == '__main__':\n main()\n"] | ['Wrong Answer', 'Accepted'] | ['s201672184', 's992732281'] | [12064.0, 12064.0] | [80.0, 78.0] | [800, 804] |
p02756 | u323045245 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nn = int(input())\nQ = [list(map(str, input().split())) for i in range(n)]\n\nfor i in range(n):\n op = Q[i]\n if len(op) == 1:\n s = s[::-1]\n elif op[1] == 1:\n s = op[2] + s\n else:\n s = s + op[2]\nprint(s)\n', "import collections\n\ns = collections.deque(list(input()))\nq = int(input())\nrev = 0 \nfor i in range(q):\n tfc = list(input().split())\n if tfc[0]=='1':\n rev = abs(rev-1) \n else:\n t,f,c = tfc\n if rev:\n if f=='1':\n s.append(c)\n else:\n s.appendleft(c)\n else:\n if f=='1':\n s.appendleft(c)\n else:\n s.append(c)\nif rev: \n t = []\n for i in range(len(s)):\n t.append(s.pop())\n print(''.join(t))\nelse:\n print(''.join(s))\n"] | ['Wrong Answer', 'Accepted'] | ['s953287156', 's931502872'] | [41520.0, 9180.0] | [2106.0, 527.0] | [244, 733] |
p02756 | u327078256 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S=input()\nQ=int(input())\nQuery=[[j for j in input().split()] for i in range(Q)]\n\nc=0\nS0=list(S)\n\nfor i in range(Q):\n if Query[i][0]=='1':\n c=c+1\n else:\n if ((Query[i][1]=='1')and(c%2==0)) or ((Query[i][1]=='2')and(c%2==1)):\n S0.appendleft(Query[i][2])\n else:\n S0.append(Query[i][2])\n\nif c%2==0:\n print(''.join(S0))\nelse:\n print(''.join(reversed(S0)))", "from collections import deque\n\nS=input()\nQ=int(input())\nQuery=[[j for j in input().split()] for i in range(Q)]\n\nc=0\nS0=deque(S)\n\nfor i in range(Q):\n if Query[i][0]=='1':\n c=c+1\n else:\n if ((Query[i][1]=='1')and(c%2==0)) or ((Query[i][1]=='2')and(c%2==1)):\n S0.appendleft(Query[i][2])\n else:\n S0.append(Query[i][2])\n\nif c%2==0:\n print(''.join(S0))\nelse:\n print(''.join(reversed(S0)))"] | ['Runtime Error', 'Accepted'] | ['s622423507', 's644000890'] | [27508.0, 32116.0] | [463.0, 550.0] | [405, 437] |
p02756 | u328364772 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["for i in range(q):\n tfc = input()\n if len(tfc) == 1:\n if rev:\n rev = False\n else:\n rev = True\n else:\n t, f, c = tfc.split()\n if f == '1':\n if rev:\n back += c\n else:\n forward += c\n else:\n if rev:\n forward += c\n else:\n back += c\n\ns = forward[::-1] + s + back\nif rev:\n s = s[::-1]\n\nprint(s)\n", "s = input()\nq = int(input())\n\nrev = False\n\nforward = ''\nback = ''\n\nfor i in range(q):\n tfc = input()\n if len(tfc) == 1:\n if rev:\n rev = False\n else:\n rev = True\n else:\n t, f, c = tfc.split()\n if f == '1':\n if rev:\n back += c\n else:\n forward += c\n else:\n if rev:\n forward += c\n else:\n back += c\n\ns = forward[::-1] + s + back\nif rev:\n s = s[::-1]\n\nprint(s)\n"] | ['Runtime Error', 'Accepted'] | ['s982754057', 's430747428'] | [3060.0, 4284.0] | [18.0, 455.0] | [461, 528] |
p02756 | u329049771 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\n\ns = input()\nq = int(input())\n\nfor query in sys.stdin:\n if query == '1':\n s = s[::-1]\n else:\n t,f,c = query.split()\n if f == '1':\n s = c + s\n elif f == '2':\n s = s + c\nprint(s)", "import sys\nfrom collections import deque\n\n\n\n\ns = deque([s for s in input()])\nprint(s)\nq = int(input())\nrev = False\n\nfor query in sys.stdin:\n if query.strip() == '1': \n if rev:\n rev = False\n else:\n rev = True\n else:\n t,f,c = query.split()\n if f == '1':\n if rev:\n s.append(c)\n else:\n s.appendleft(c)\n elif f == '2':\n if rev:\n s.appendleft(c)\n else:\n s.append(c)\nif rev == True:\n s.reverse()\nprint(''.join(s))", "import sys\nfrom collections import deque\n\n\n\n\ns = deque([s for s in input()])\nprint(s)\nq = int(input())\nrev = False\n\nfor query in sys.stdin:\n if query.strip() == '1': \n if rev:\n rev = False\n else:\n rev = True\n else:\n t,f,c = query.split()\n if f == '1':\n if rev:\n s.append(c)\n else:\n s.appendleft(c)\n elif f == '2':\n if rev:\n s.appendleft(c)\n else:\n s.append(c)\nif rev == True:\n s.reverse()\nprint(s)\nprint(''.join(s))", "import sys\nfrom collections import deque\n\n\n\n\ns = deque([s for s in input()])\nq = int(input())\nrev = False\n\nfor query in sys.stdin:\n if query.strip() == '1': \n if rev:\n rev = False\n else:\n rev = True\n else:\n t,f,c = query.split()\n if f == '1':\n if rev:\n s.append(c)\n else:\n s.appendleft(c)\n elif f == '2':\n if rev:\n s.appendleft(c)\n else:\n s.append(c)\nif rev == True:\n s.reverse()\nprint(''.join(s))"] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s383867058', 's581477686', 's869376503', 's459726452'] | [3772.0, 9172.0, 12496.0, 8548.0] | [2104.0, 168.0, 187.0, 155.0] | [243, 741, 750, 732] |
p02756 | u329799519 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\n\n\ndef formation():\n global S, Q\n\n ls = list(S)\n do_rev = False\n for _ in range(Q):\n t_str = input()\n\n if t_str[0] == '1':\n do_rev = not do_rev\n else:\n splited = t_str.split(' ')\n f = splited[1]\n c = splited[2]\n if f == '1':\n if do_rev:\n ls.append(c)\n else:\n ls.insert(0, c)\n else:\n if do_rev:\n ls.insert(0, c)\n else:\n ls.append(c)\n print(ls)\n\n if do_rev:\n ls.reverse()\n\n return ''.join(ls)\n\n\nprint(formation())\n", 'S = input()\nQ = int(input())\n\n\nclass Node:\n def __init__(self, value=None, prev=None, next=None):\n self.value = value\n self.prev = prev\n self.next = next\n\n def __str__(self):\n return str(self.value)\n\n\nclass LinkedList:\n def __init__(self, initial_string=None):\n self.first = Node()\n self.last = Node()\n self.first.next = self.last\n self.last.prev = self.first\n self.should_reverse = False\n for s in initial_string:\n self.insert_last(s)\n\n def _insert_first(self, value=None):\n prev_next = self.first.next\n self.first.next = Node(value, self.first, prev_next)\n prev_next.prev = self.first.next\n\n def _insert_last(self, value=None):\n prev_prev = self.last.prev\n self.last.prev = Node(value, prev_prev, self.last)\n prev_prev.next = self.last.prev\n\n def insert_first(self, value=None):\n if self.should_reverse:\n self._insert_last(value)\n else:\n self._insert_first(value)\n\n def insert_last(self, value=None):\n if self.should_reverse:\n self._insert_first(value)\n else:\n self._insert_last(value)\n\n def set_reverse(self):\n self.should_reverse = not self.should_reverse\n\n def _print(self):\n node = self.first.next\n while node is not None:\n if node.value is not None:\n print(node, end="")\n node = node.next\n print("")\n\n def _print_reverse(self):\n node = self.last.prev\n while node is not None:\n if node.value is not None:\n print(node, end="")\n node = node.prev\n print("")\n\n def print_list(self):\n if self.should_reverse:\n self._print_reverse()\n else:\n self._print()\n\n\ndef formation():\n global S, Q\n\n linked_list = LinkedList(S)\n\n for _ in range(Q):\n t_str = input()\n\n if t_str[0] == \'1\':\n linked_list.set_reverse()\n else:\n split = t_str.split(\' \')\n f = split[1]\n c = split[2]\n if f == \'1\':\n linked_list.insert_first(c)\n else:\n linked_list.insert_last(c)\n\n linked_list.print_list()\n\n\nformation()\n'] | ['Runtime Error', 'Accepted'] | ['s614167425', 's465219533'] | [136008.0, 54652.0] | [1665.0, 1573.0] | [695, 2300] |
p02756 | u334904929 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\n\nflag = 1\ns1 = ''\ns2 = ''\n\nfor i in range(Q):\n\tq = input()\n\tif len(q) == 1:\n\t\tflag = flag * (-1)\n\telse:\n\t\tT,F,C = q.split(' ')\n\t\tif flag == 1:\n\t\t\tif int(F) == 1:\n\t\t\t\ts1 = s1 + C\n\t\t\telse:\n\t\t\t\ts2 = C + s2\n\t\telse:\n\t\t\tif int(F) == 1:\n\t\t\t\ts2 = C + s2\n\t\t\telse:\n\t\t\t\ts1 = s1 + C\nif flag == 1:\n\tprint(s1 + S + s2)\nelse:\n\tprint(s2 + S + s1)\n\n", "S = input()\nQ = int(input())\n\nflag = 1\ns1 = ''\n\nfor i in range(Q):\n\tq = input()\n\tif len(q) == 1:\n\t\ts1,S = S,s1\n\telse:\n\t\tT,F,C = q.split(' ')\n\t\tif int(F) == 1:\n\t\t\ts1 = s1 + C\n\t\telse:\n\t\t\tS = S + C\n\nprint(s1[::-1] + S)\n"] | ['Wrong Answer', 'Accepted'] | ['s092332781', 's210595507'] | [4356.0, 4480.0] | [830.0, 523.0] | [361, 216] |
p02756 | u335950809 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def sr(x):\n y = ''\n for i in range(len(x)-1,-1,-1):\n y = '%s%s' %(y,x[i])\n print(y)\n print(y) \n return y\n\ns = input()\nq = int(input())\n\nfor i in range(q):\n x = input().split()\n \n if (x[0] == '1'):\n #s = s[::-1]\n s = sr(s)\n else:\n s = '%s%s'%(x[2],s) if (x[1] == '1') else '%s%s'%(s,x[2])\n\nprint(s)\n", "rflag = 0\ns = [i for i in input()]\nq = int(input())\n\nfor i in range(q):\n x = input().split()\n \n if(x[0] == '1'):\n rflag = rflag + 1\n \n else:\n if((rflag % 2) == 0):\n rflag = 0\n else:\n s = s[::-1]\n rflag = 0\n \n s.insert(0,x[2]) if(x[1]=='1') else s.append(x[2])\n\nprint(''.join(s))\n", "rflag = 0\ns = [i for i in input()]\nq = int(input())\n\nfor i in range(q):\n x = input().split()\n \n if(x[0] == '1'):\n rflag = rflag + 1\n \n else:\n if((rflag % 2) == 0):\n rflag = 0\n else:\n s = s[::-1]\n rflag = 0\n \n s.insert(0,x[2]) if(x[1]=='1') else s.append(x[2])\n\ns if((rflag % 2) == 0) else s = s[::-1]\n\nprint(''.join(s))\n", 'from collections import deque\n\nrevFlag = False\n\ns = deque(input())\nq = int(input())\n\nfor i in range(q):\n a,b,c, *_ = input().split() + [None, None]\n \n if(a == \'1\'):\n revFlag = not revFlag\n \n else:\n b = int(b)\n if(revFlag):\n b = (int(b)%2)+1\n \n if(b == 1):\n s.appendleft(c)\n else:\n s.append(c)\n \n #print(_,*s, sep="")\n\nif(revFlag):\n s.reverse()\n \nprint(*s, sep=\'\')\n'] | ['Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s029923932', 's421284566', 's715224487', 's574512268'] | [134516.0, 6072.0, 3064.0, 12272.0] | [2104.0, 2108.0, 17.0, 734.0] | [360, 383, 424, 478] |
p02756 | u337751290 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def main():\n S = input()\n Q = int(input())\n queries = [input() for _ in range(Q)]\n\n reverse = False\n\n for e in queries:\n if e[0] == '1':\n reverse = not reverse\n else:\n T, F, C = e.split()\n if F == '2': F = True\n else: F = False\n\n if reverse ^ F:\n continue\n \n # S += C\n else:\n continue\n \n # S = C + S\n # print(S)\n\n if reverse:\n S = S[::-1]\n\n print(S)\n\n\n\nif __name__ == '__main__':\n main()\n", "def main():\n S = input()\n Q = int(input())\n queries = [input() for _ in range(Q)]\n\n reverse = False\n\n for e in queries:\n if e[0] == '1':\n reverse = not reverse\n else:\n T, F, C = e.split()\n if F == '2': F = True\n else: F = False\n\n if reverse ^ F:\n \n S += C\n else:\n continue\n \n # S = C + S\n # print(S)\n\n if reverse:\n S = S[::-1]\n\n print(S)\n\n\n\nif __name__ == '__main__':\n main()\n", 'def main():\n S = input()\n Q = int(input())\n queries = [input() for _ in range(Q)]\n\n reverse = False\n front = ""\n\n for e in queries:\n if e[0] == \'1\':\n reverse = not reverse\n else:\n T, F, C = e.split()\n if F == \'2\': F = True\n else: F = False\n\n if reverse ^ F:\n \n S += C\n else:\n # continue\n \n front += C\n # print(S)\n\n if reverse:\n S = S[::-1]\n S = S + front\n else:\n S = front[::-1] + S\n\n print(S)\n \n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s134389514', 's630995597', 's883968350'] | [15992.0, 16120.0, 16960.0] | [319.0, 325.0, 347.0] | [630, 603, 721] |
p02756 | u343823529 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import copy\nimport itertools\n\ns = input()\nq = int(input())\n#s= list(input())\n\nct = 0\nls = []\nrs = []\nfor i in range(q):\n qtmp = input().split()\n "qtmp = [2,1,\'c\']\n t = int(qtmp[0])\n if(t == 1):\n ct += 1\n ct = ct % 2\n else:\n f = int(qtmp[1])\n if(ct == f):\n rs.append( qtmp[2])\n else:\n ls.append( qtmp[2])\nif(ct == 1):\n tmp = rs\n rs = ls\n ls = tmp\nfor i in range(len(ls)):\n print(ls[len(ls)-i-1], end=\'\')\nprint(s, end=\'\')\nfor i in range(len(rs)):\n print(rs[i], end=\'\')\nprint("")', 'import copy\nimport itertools\n\ns = input()\nq = int(input())\n#s= list(input())\n\nct = 0\nls = []\nrs = []\nfor i in range(q):\n qtmp = input().split()\n #qtmp = [2,1,\'c\']\n t = int(qtmp[0])\n if(t == 1):\n ct += 1\n ct = ct % 2\n else:\n f = int(qtmp[1])\n if(ct+1 == f):\n ls.append( qtmp[2])\n else:\n rs.append( qtmp[2])\nif(ct == 1):\n tmp = rs\n rs = ls\n ls = tmp\n s = s[::-1]\nfor i in range(len(ls)):\n print(ls[len(ls)-i-1], end=\'\')\nprint(s, end=\'\')\nfor i in range(len(rs)):\n print(rs[i], end=\'\')\nprint("")'] | ['Runtime Error', 'Accepted'] | ['s506639041', 's028740663'] | [3064.0, 6916.0] | [18.0, 748.0] | [563, 581] |
p02756 | u344030307 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\ns = deque(input())\nq = int(input())\n\nqq = [list(input().split()) for i in range(q)]\nqq.append([0, 0, 0])\n\norder = 0\ncnt = 0\nf = []\n\nfor i in qq:\n if i[0] != order:\n if order == 1:\n if cnt%2 == 1:\n s.reverse()\n cnt = 0\n elif order == 21:\n s.extendleft(f)\n f = []\n else:\n s.extend(f)\n f = []\n\n\n if i[0] == '1':\n order = 1\n cnt += 1\n else:\n if i[1] == '1':\n order = 21\n f.insert(0, i[2])\n else:\n order = 22\n f.append(i[2])\n\nprint(s)\nprint(''.join(s))", "from collections import deque\n\ns = deque(input())\nq = int(input())\n\nqq = [list(input().split()) for i in range(q)]\n\n\nrl = 1\nrlrl = 1\nfleft = deque()\nfright = deque()\n\nfor i in qq:\n if i[0] == '1':\n rl *= -1\n else:\n if i[1] == '1':\n if rl == 1:\n fleft.appendleft(i[2])\n else:\n fright.append(i[2])\n else:\n if rl == 1:\n fright.append(i[2])\n else:\n fleft.appendleft(i[2])\n\nfleft.reverse() \n \ns.extendleft(fleft)\ns.extend(fright) \n\nif rl == -1:\n s.reverse()\n\nprint(''.join(s))"] | ['Wrong Answer', 'Accepted'] | ['s986629010', 's847527991'] | [37380.0, 36460.0] | [2206.0, 360.0] | [561, 552] |
p02756 | u349444371 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\nS=input()\ns=deque(S)\nQ=int(input())\nQue=[list(map(str, input().split())) for _ in range(Q)]\n#print(Que)\nfor i in range(Q):\n if Que[i][0]=="1":\n s=s[::-1]\n elif Que[i][0]=="2":\n if Que[i][1]=="2":\n s.append(Que[i][2])\n elif Que[i][1]=="1":\n s.appendleft(Que[i][2])\nans="".join(s)\nprint(ans)\n', 'from collections import deque\nS=input()\ns=deque(S)\nQ=int(input())\nQue=[list(map(str, input().split())) for _ in range(Q)]\n#print(Que)\na=0\nfor i in range(Q):\n if Que[i][0]=="1":\n a+=1\n elif Que[i][0]=="2":\n if a%2==0:\n if Que[i][1]=="2":\n s.append(Que[i][2])\n elif Que[i][1]=="1":\n s.appendleft(Que[i][2])\n else:\n if Que[i][1]=="1":\n s.append(Que[i][2])\n elif Que[i][1]=="2":\n s.appendleft(Que[i][2])\ns=list(s)\nif a%2==1:\n s=s[::-1]\nans="".join(s)\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s354566105', 's299886346'] | [44660.0, 46196.0] | [672.0, 702.0] | [369, 592] |
p02756 | u350093546 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\n\nz=list(input())\nQ=deque()\nQ.append((z))\nq=int(input())\n\ncnt=0\n\nfor i in range(q):\n x=input()\n if x[0]=='1':\n cnt+=1\n cnt%=2\n \n elif x[0]=='2':\n if x[2]=='1':\n if cnt%2==0:\n Q.appendleft(x[4])\n else:\n Q.append(x[4])\n\n else:\n if cnt%2==0:\n Q.append(x[4])\n else:\n Q.appendleft(x[4])\n \nif cnt%2==1:\n Q.reverse()\n\n\nprint(''.join(Q))", "from collections import deque\n\nz=list(input())\nQ=deque()\nQ.append(z)\nq=int(input())\n\ncnt=0\n\nfor i in range(q):\n x=input()\n if x[0]=='1':\n cnt+=1\n cnt%=2\n \n elif x[0]=='2':\n if x[2]=='1':\n if cnt%2==0:\n Q.appendleft(x[4])\n else:\n Q.append(x[4])\n\n else:\n if cnt%2==0:\n Q.append(x[4])\n else:\n Q.appendleft(x[4])\n \nif cnt%2==1:\n Q.reverse()\n\n\nprint(''.join(Q))", "from collections import deque\n\nz=list(input())\nQ=deque()\nfor i in z:\n Q.append(i)\nq=int(input())\n\ncnt=0\n\nfor i in range(q):\n x=input()\n if x[0]=='1':\n cnt+=1\n cnt%=2\n \n elif x[0]=='2':\n if x[2]=='1':\n if cnt%2==0:\n Q.appendleft(x[4])\n else:\n Q.append(x[4])\n\n else:\n if cnt%2==0:\n Q.append(x[4])\n else:\n Q.appendleft(x[4])\n \nif cnt%2==1:\n Q.reverse()\n\n\nprint(''.join(Q))"] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s945211626', 's992936688', 's676578981'] | [13204.0, 13032.0, 15008.0] | [291.0, 288.0, 304.0] | [454, 452, 466] |
p02756 | u353919145 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def string():\n s = input()\n q = int(input())\n l = ''\n r = ''\n re = False\n while q > 0:\n t = list(input().strip().split())\n if t[0] == 1:\n re = not re\n else:\n if re:\n if t[1] == 2:\n l = t[2] + l\n else:\n r = r + t[2]\n else:\n if t[1] == 2:\n l = t[2] + l\n else:\n r = r + t[2]\n q -= 1\n s = l + s + r\n if re:\n s = s[::-1]\n print(s)\nstring()", "S = input()\nQ = int(input())\nflip = 0\nhead = []\ntail = []\nfor i in range(Q):\n Query = input().split()\n if len(Query) == 3:\n T,F,C = Query\n F = int(F)-1\n if F^flip == 1:\n tail.append(C)\n else:\n head.append(C)\n else:\n flip ^= 1\nif flip:\n head, tail = tail, head\n S = S[::-1]\nhead = ''.join(head[::-1])\ntail = ''.join(tail)\nprint(head+S+tail)"] | ['Runtime Error', 'Accepted'] | ['s802785729', 's541228387'] | [4212.0, 12024.0] | [480.0, 357.0] | [565, 369] |
p02756 | u357949405 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\n\nS = input()\nq = int(input())\n\nis_s0_head = True\ntail = len(S)-1\n\nqueue = deque(S)\n\nfor _ in range(q):\n # print(S)\n Q = list(input().split())\n if Q[0] == "1":\n is_s0_head = not is_s0_head\n else:\n if Q[1] == "1":\n if is_s0_head:\n queue.appendleft(Q[2])\n else:\n queue.append(Q[2])\n else:\n if is_s0_head:\n queue.append(Q[2])\n else:\n queue.appendleft(Q[2])\n\nif is_s0_head:\n print("".join(list(S)))\nelse:\n print("".join(list(S)[::-1]))\n', 'from collections import deque\n\nS = input()\nq = int(input())\n\nis_s0_head = True\ntail = len(S)-1\n\nqueue = deque(S)\n\nfor _ in range(q):\n \n Q = list(input().split())\n if Q[0] == "1":\n is_s0_head = not is_s0_head\n else:\n if Q[1] == "1":\n if is_s0_head:\n queue.appendleft(Q[2])\n else:\n queue.append(Q[2])\n else:\n if is_s0_head:\n queue.append(Q[2])\n else:\n queue.appendleft(Q[2])\n\nif is_s0_head:\n print("".join(list(queue)))\nelse:\n print("".join(list(queue)[::-1]))\n'] | ['Wrong Answer', 'Accepted'] | ['s822345184', 's484874104'] | [7284.0, 10100.0] | [465.0, 498.0] | [604, 616] |
p02756 | u360061665 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['\nS = input()\nQ = int(input())\nf = True\nhead = []\ntail = []\nfor i in range(Q):\n query = input().split(\' \')\n if len(query) == 1:\n f = not f\n else:\n if (query[1] == \'1\' and f) or (query[1] == \'0\' and not f):\n head.append(query[2])\n else:\n tail.append(query[2])\n\nS = \'\'.join(head)+S+\'\'.join(tail)\nif not f:\n S = S[::-1]\nprint(S)\n\n# start = time.time()\n# elapsed_time = time.time() - start\n# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")\n', '\nS = input()\nQ = int(input())\nf = True\nfor i in range(Q):\n query = input().split(\' \')\n if len(query) == 1:\n f = not f\n else:\n if (query[1] == \'1\' and f) or (query[1] == \'0\' and not f):\n S = query[2]+S\n else:\n S = S+query[2]\n\nprint(S)\n\n# start = time.time()\n# elapsed_time = time.time() - start\n# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")\n', '\nS = input()\nQ = int(input())\nf = True\nhead = []\ntail = []\nfor i in range(Q):\n query = input().split(\' \')\n if len(query) == 1:\n f = not f\n else:\n if (query[1] == \'1\' and f) or (query[1] == \'2\' and not f):\n head.append(query[2])\n else:\n tail.append(query[2])\n\nS = \'\'.join(head)[::-1]+S+\'\'.join(tail)\nif not f:\n S = S[::-1]\nprint(S)\n\n# start = time.time()\n# elapsed_time = time.time() - start\n# print("elapsed_time:{0}".format(elapsed_time) + "[sec]")\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s590092362', 's703179461', 's366967416'] | [5640.0, 4064.0, 5720.0] | [419.0, 2104.0, 413.0] | [511, 417, 517] |
p02756 | u360515075 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\nS = deque(list(input()))\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if (int(b[0]) + f) % 2 == 0 :\n S.append(b[1])\n else:\n S.appendleft(b[1])\nfor i in range(len(S)):\n if f % 2 == 1:\n print (S[-i-1], end="")\n else:\n print (*S, sep="")\n', 'from collections import deque\nS = deque(input().split())\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if (int(b[0]) + f) % 2 == 0 :\n S.appendleft(b[1])\n else:\n S.append(b[1])\nfor i in range(len(S)):\n if f % 2 == 0:\n print (S[-i-1], end="")\n else:\n print (S[i], end="")', 'from collections import deque\nS = deque(input().split())\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if (int(b[0]) + f) % 2 == 0 :\n S.appendleft(b[1])\n else:\n S.append(b[1])\nif f % 2 == 0:\n for i in range(len(S)):\n print (S[-i-1], end="")\n print ()\nelse:\n print (*S, sep="")\n', 'from collections import deque\nS = deque(input().split())\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if (int(b[0]) + f) % 2 == 0 :\n S.appendleft(b[1])\n else:\n S.append(b[1])\nif f % 2 == 0:\n for i in range(len(S)):\n print (S[-i-1], end="")\nelse:\n print (*S, sep="")', 'from collections import deque\nS = deque(input().split())\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if int(b[0]) + f % 2 ==0 :\n S.leftappend(b[1])\n else:\n S.append(b[1])\nif f % 2 == 0:\n for i in range(len(S)):\n print (S[-i-1], end="")\nelse:\n print (*S, sep="")', 'from collections import deque\nS = deque(list(input()))\nQ = int(input())\nf = 0\nfor _ in range(Q):\n a, *b = input().split()\n f += int(a)\n if a == "2":\n if (int(b[0]) + f) % 2 == 1 :\n S.appendleft(b[1])\n else:\n S.append(b[1])\nD = list(S)\nprint ("".join(D) if f % 2 == 0 else "".join(D[::-1]))'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s061110874', 's242338928', 's574023764', 's806231408', 's875949953', 's535759174'] | [17288.0, 6768.0, 9584.0, 9584.0, 9452.0, 10340.0] | [2108.0, 1902.0, 1890.0, 1849.0, 1592.0, 678.0] | [342, 345, 353, 339, 336, 308] |
p02756 | u361381049 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["from collections import deque\ns = list(input())\ns = deque(s)\nn = int(input())\ncnt = 0\nfor i in range(n):\n q = list(map(str,input().split()))\n if q[0] == '1':\n cnt += 1\n else:\n if cnt % 2 == 0:\n if q[1] == '1':\n s.appendleft(q[2])\n else:\n s.append(q[2])\n else:\n if q[1] == '1':\n s.append(q[2])\n else:\n s.appendleft(q[2])\n print(q)\nif cnt % 2 != 0:\n s.reverse()\nprint(''.join(list(s)))\n", "from collections import deque\ns = list(input())\ns = deque(s)\nn = int(input())\ncnt = 0\nfor i in range(n):\n q = list(map(str,input().split()))\n if q[0] == '1':\n cnt += 1\n else:\n if cnt % 2 == 0:\n if q[1] == '1':\n s.appendleft(q[2])\n else:\n s.append(q[2])\n else:\n if q[1] == '1':\n s.append(q[2])\n else:\n s.appendleft(q[2])\n #print(q)\nif cnt % 2 != 0:\n s.reverse()\nprint(''.join(list(s)))"] | ['Wrong Answer', 'Accepted'] | ['s340317716', 's682656440'] | [11748.0, 8676.0] | [1952.0, 680.0] | [524, 524] |
p02756 | u363421241 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = [input()]\nq = int(input())\n\ncnt = 0\nfor _ in range(q):\n i = input().split()\n t = int(i[0])\n\n if t == 1:\n cnt += 1\n else:\n f = int(i[1])\n c = i[2]\n if (cnt % 2 == 0 and f == 1) or (cnt % 2 == 1 and f == 2):\n # s.insert(0, i[2])\n s.append(i[2])\n else:\n s.append(i[2])\nprint(''.join(s) if cnt % 2 == 0 else ''.join(s[::-1]))", "from collections import deque\ns = deque(input())\nq = int(input())\n\ncnt = 0\nfor _ in range(q):\n i = input().split()\n t = int(i[0])\n\n if t == 1:\n cnt += 1\n else:\n f = int(i[1])\n c = i[2]\n if (cnt % 2 == 0 and f == 1) or (cnt % 2 == 1 and f == 2):\n s.appendleft(i[2])\n else:\n s.append(i[2])\n\nif cnt % 2 == 1:\n s.reverse()\nprint(''.join(s))"] | ['Wrong Answer', 'Accepted'] | ['s323882187', 's841363184'] | [12144.0, 14168.0] | [369.0, 384.0] | [405, 408] |
p02756 | u364318561 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["def main(s,end,start,perse):\n start.reverse()\n start.append(''.join(s))\n start.append(''.join(end))\n print(start)\n print(''.join(start))\ndef conv(s):\n a = []\n for i in range(len(s)):\n a.append(s[i])\n return a\nperse = 1\nstart = []\nend = []\n \ns = input()\nq = int(input())\nfor i in range(q):\n query = input().split()\n query[0] = int(query[0])\n if query[0] == 1:\n perse = -perse\n else:\n query[1] = int(query[1])\n if (int(query[1])*2-3)*perse == 1:\n end.append(query[2])\n else:\n start.append(query[2])\ns = conv(s)\nif perse == -1:\n start.reverse()\n s.reverse()\n end.reverse()\nmain(s,end,start,perse)", "def main(s,end,start,perse):\n start.reverse()\n start.append(''.join(s))\n start.append(''.join(end))\n if perse == -1:\n start.reverse()\n print(''.join(start))\ndef conv(s):\n a = []\n for i in range(len(s)):\n a.append(s[i])\n return a\nperse = 1\nstart = []\nend = []\n \ns = input()\nq = int(input())\nfor i in range(q):\n query = input().split()\n query[0] = int(query[0])\n if query[0] == 1:\n perse = -perse\n else:\n query[1] = int(query[1])\n if (int(query[1])*2-3)*perse == 1:\n end.append(query[2])\n else:\n start.append(query[2])\ns = conv(s)\nif perse == -1:\n s.reverse()\n end.reverse()\nmain(s,end,start,perse)"] | ['Wrong Answer', 'Accepted'] | ['s294768270', 's644242557'] | [8432.0, 6516.0] | [594.0, 600.0] | [697, 704] |
p02756 | u367965715 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["s = input()\nq = int(input())\nfor _ in range(q):\n query = input().split()\n if query[0] == '1':\n s = s[::-1]\n else:\n if query[1] == '1':\n s = query[2] + s\n else:\n s = s + query[2]\n print(s)\n", "from collections import deque\n\nis_reverse = False\ns = deque(input())\nq = int(input())\nfor _ in range(q):\n query = input().split()\n if query[0] == '1':\n is_reverse = not is_reverse\n else:\n if (not is_reverse and query[1] == '1') or (is_reverse and query[1] == '2'):\n s.appendleft(query[2])\n else:\n s.append(query[2])\nprint(''.join(s)[::-1]) if is_reverse else print(''.join(s))\n"] | ['Runtime Error', 'Accepted'] | ['s545324865', 's766831821'] | [134352.0, 8436.0] | [151.0, 400.0] | [243, 429] |
p02756 | u369752439 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['def do(s, query, isReverse):\n if(query[0] == "1"):\n return s, isReverse * -1\n else:\n if(query[1] == "1"):\n if(isReverse == 1):\n return "".join([s, query[2]]), isReverse\n else:\n return "".join([query[2], s]), isReverse\n else:\n if(isReverse == 1):\n return "".join([query[2], s]), isReverse\n else:\n return "".join([s, query[2]]), isReverse\n\ns = input()\nq = int(input())\nisReverse = -1\nfor i in range(q):\n query = input().split()\n #s, isReverse = do(s, query, isReverse)\nif(isReverse == -1):\n print(s)\nelse:\n print(s[::-1])', 's = input()\nq = int(input())\n\nans = [" " for n in range(2*q + 1)]\nans[q] = s\nfrontIndex = q - 1\nendIndex = q + 1\nisReverse = -1\n\nfor i in range(q):\n query = input().split()\n if(query[0] == "1"):\n isReverse *= -1\n else:\n if(query[1] == "1"):\n if(isReverse == 1):\n ans[endIndex] = query[2] \n endIndex += 1\n else:\n ans[frontIndex] = query[2]\n frontIndex -= 1\n else:\n if(isReverse == 1):\n ans[frontIndex] = query[2] \n frontIndex -= 1\n else:\n ans[endIndex] = query[2]\n endIndex += 1\nans = "".join(ans).strip()\nif(isReverse == -1):\n print(ans)\nelse:\n print(ans[::-1])'] | ['Wrong Answer', 'Accepted'] | ['s019312769', 's819948572'] | [3316.0, 7180.0] | [308.0, 425.0] | [662, 762] |
p02756 | u370721525 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['import sys\ns = str(input())\nQ = int(input())\nq = sys.stdin.readlines()\nfor i in q:\n if i[0] == 1:\n s = alpha[::-1]\n elif i[1] == 1:\n s.appendleft(i[2])\n else:\n s.append(i[2])\nprint(s)', 'from collections import deque\nimport sys\ns = deque(list(input()))\nQ = int(input())\ncnt = 0\n\nfor i in range(Q):\n q = list(input().split())\n if q[0] == \'1\':\n cnt = (cnt+1) % 2\n elif q[1] == \'1\':\n if cnt == 0:\n s.appendleft(q[2])\n else:\n s.append(q[2])\n else:\n if cnt == 0:\n s.append(q[2])\n else:\n s.appendleft(q[2])\n\nif cnt == 1:\n s.reverse()\nprint("".join(s))'] | ['Runtime Error', 'Accepted'] | ['s916550181', 's244178973'] | [15872.0, 8804.0] | [40.0, 486.0] | [195, 398] |
p02756 | u371385198 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\ninput = sys.stdin.readline\n\nS = input().strip()\nQ = int(input())\n\nfor i in range(Q):\n q = input().split()\n if q[0] == '1':\n S.reverse()\n elif q[0] == '2':\n if q[1] == '1':\n S = '{}{}'.format(q[2], S)\n elif q[1] == '2':\n S = '{}{}'.format(S, q[2])\n\nprint(S)\n", "import sys\nfrom collections import deque\ninput = sys.stdin.readline\n\nS = deque(input().strip())\nQ = int(input())\nflag = 0\n\nfor i in range(Q):\n q = input().split()\n if q[0] == '1':\n flag = 1 if not flag else 0\n elif q[0] == '2':\n if q[1] == '1':\n S.appendleft(q[2]) if not flag else S.append(q[2])\n elif q[1] == '2':\n S.append(q[2]) if not flag else S.appendleft(q[2])\n\nprint(''.join(S)) if not flag else print(''.join(reversed(S)))\n"] | ['Runtime Error', 'Accepted'] | ['s721153554', 's026215047'] | [3700.0, 8436.0] | [2104.0, 180.0] | [320, 484] |
p02756 | u373047809 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['s = input()\nq = int(input())\nfor _ in range(q):\n l = input()\n if ipt == "1":\n s = s[::-1]\n else:\n t, f, c = l.split()\n if f == "1":\n st = c + st\n else:\n st += c\nprint(st)', 'def input(): return sys.stdin.readline().strip()\nst = input()\nq = int(input())\nfor i in range(q):\n ipt = input()\n if ipt == "1":\n st = st[::-1]\n else:\n _, f, c = input().split()\n if f == "1":\n st = st + c\n else:\n st = c + st\nprint(st)\n', 's, _, q = open(0)\ng = ""\nfor q in q:\n p, f, c = q.split()\n if p == "1":\n g, s = s, g\n else:\n if f == "1":\n g += c\n else:\n s += c\nprint(g[::-1] + s)', '#!/usr/bin/env python3\ns, _, *q = open(0)\ng = ""\ns = s.strip()\nfor q in q:\n q = q.strip().split()\n if q[0] == "1":\n g, s = s, g\n else:\n if q[1] == "1":\n g += q[2]\n else:\n s += q[2]\nprint(g[::-1] + s)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s053298058', 's360803206', 's923435242', 's973982174'] | [3188.0, 2940.0, 3188.0, 16160.0] | [18.0, 18.0, 18.0, 152.0] | [229, 294, 169, 221] |
p02756 | u375616706 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['S=input()\nQ=int(input())\nhead=""\ntail=""\nrev=False\n\nfor _ in range(Q):\n q = input().split()\n if len(q)==1:\n rev != rev\n else:\n if rev ^ (q[1]=="1"):\n head+=q[2]\n else:\n tail+=q[2]\nif rev:\n print(tail[::-1]+S[::-1]+head)\nelse:\n print(head[::-1]+S+tail)\n', 'S=input()\nQ=int(input())\nhead=""\ntail=""\nrev=False\n\nfor _ in range(Q):\n q = input().split()\n if len(q)==1:\n rev = not rev\n else:\n if rev ^ (q[1]=="1"):\n head+=q[2]\n else:\n tail+=q[2]\nif rev:\n print(tail[::-1]+S[::-1]+head)\nelse:\n print(head[::-1]+S+tail)\n'] | ['Wrong Answer', 'Accepted'] | ['s708018400', 's134061281'] | [4340.0, 4340.0] | [460.0, 478.0] | [310, 313] |
p02756 | u375695365 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from collections import deque\ns=str(input())\nc=0\nn=1\nq=int(input())\nfor i in range(q):\n a=input().strip()\n a=list(a)\n #print(a)\n if int(a[0])==1:\n #print("DFGHJ")\n c=+1\n n+=1\n if c%2==1:\n if int(a[0])==2:\n #print(a[2])\n s=list(s)\n if int(a[2])==2:\n s=deque(s)\n #print(s)\n s.appendleft(str(a[4]))\n #print(s)\n s=list(s)\n #print("DFGH",s)\n else:\n s.append(str(a[4]))\n s=\'\'.join(s)\n #print(s) \n for i in range(n%2):\n s=s[::-1]\n n=0\n else: \n if int(a[0])==2:\n #print(a[2])\n s=list(s)\n if int(a[2])==1:\n s=deque(s)\n #print(s)\n s.appendleft(str(a[4]))\n #print(s)\n s=list(s)\n #print("DFGH",s)\n else:\n \n s.append(str(a[4]))\n s=\'\'.join(s)\n #print(s) \n for i in range(n%2):\n s=s[::-1]\n n=0\n\nprint(s)\n', 'from collections import deque\ns=str(input())\n\nfront = ""\nback = ""\n\nnow_swap = 0\nq=int(input())\nfor i in range(q):\n a = input().strip()\n a = list(a)\n \n if a[0] == "1":\n if now_swap == 0:\n now_swap = 1\n else: #now_step == 1:\n now_swap = 0\n else:\n if now_swap == 1:\n if a[2] == "1":\n # print("back")\n back+=a[4]\n\n else: #a[1]==2:\n ## print("f 2")\n front = a[4] + front\n\n else: #now_step == 0:\n if a[2] == "1":\n front = a[4] + front\n\n else: #a[1]==2:\n \n back+=a[4]\nans= front + s + back\n#print(front,a,back)\nif now_swap == 1:\n \n print(ans[::-1])\nelse:\n print(ans)\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s566118508', 's776057871'] | [5860.0, 4864.0] | [2104.0, 1607.0] | [1173, 878] |
p02756 | u378234362 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["string = input()\nnum = int(input())\ndata = [input().split(' ') for i in range(kai)]\n\nfor i in range(num):\n if(data[i][0] == '1'):\n if(len(string) == 2):\n string = string[1] + string[0]\n elif(len(string) >= 3):\n string = string[-1] + string[1:-1] + string[0]\n \n else:\n if(data[i][1] == '1'):\n string = data[i][2] + string\n else:\n string = string + data[i][2]\n\nprint(string)\n", "string = input()\nkai = int(input())\ndata = [input().split(' ') for i in range(kai)]\nkey = 0 #0 start\n\nfor i in range(kai):\n if(data[i][0] == '1'):\n key = 1\n elif(data[i][1] == '1'):\n string = data[i][2] + string\n else:\n string = string + data[i][2]\nif(key == 0):\n print(string)\nelse:\n print(string[::-1])\n", "string = input()\nkai = int(input())\ndata = [input().split(' ') for i in range(kai)]\nkey = 0 #0 start\nformer = []\nlatter = []\n\nfor i in range(kai):\n if(data[i][0] == '1'):\n key = (key + 1) % 2\n elif((int(data[i][1]) + key) % 2 == 1):\n former.append(data[i][2])\n else:\n latter.append(data[i][2])\n\nstring = ''.join(former[::-1]) + string + ''.join(latter)\nif(key == 0):\n print(string)\nelse:\n print(string[::-1])\n"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s434457707', 's861809354', 's104460564'] | [3188.0, 41760.0, 42396.0] | [17.0, 2106.0, 518.0] | [458, 342, 446] |
p02756 | u380524497 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import sys\nfrom collections import deque\ninput = sys.stdin.readline\n\nreverse = 0\nS = deque(list(input()))\nq = int(input())\n\nfor _ in range(q):\n query = input()\n if query[0] == '1':\n reverse = 1 - reverse\n continue\n\n _, f, c = query.split()\n f = int(f)\n action = (reverse + f) % 2\n if action:\n S.appendleft(c)\n else:\n S.append(c)\n\nif reverse:\n S.reverse()\n \nprint(''.join(S))\n", "import sys\nfrom collections import deque\n\n\nreverse = 0\nS = deque(list(input()))\nq = int(input())\n\nfor query in sys.stdin:\n if query[0] == '1':\n reverse = 1 - reverse\n continue\n\n _, f, c = query.split()\n f = int(f)\n action = (reverse + f) % 2\n if action:\n S.appendleft(c)\n else:\n S.append(c)\n\nif reverse:\n S.reverse()\n\nprint(''.join(S))"] | ['Wrong Answer', 'Accepted'] | ['s423842308', 's501444587'] | [8548.0, 8420.0] | [266.0, 242.0] | [430, 384] |
p02756 | u380791283 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['str = input()\ntimes = int(input())\nrevers = 0\nhead = ""\ntail = ""\nfor i in range(times):\n com = input().split()\n if com[0] == "1":\n if revers == 0:\n revers = 1:\n else :\n revers = 0\n \n else :\n if com[1] == "1":\n if revers == 0:\n head = com[2]+head\n else :\n tail = tail + com[2]\n else : \n if revers == 1:\n head = com[2]+head\n else :\n tail = tail + com[2] \nstr = head + str + tail\nif revers == 1:\n str = str[::-1]\n \nprint(str)', 'str = input()\ntimes = int(input())\nrevers = 0\nhead = ""\ntail = ""\nfor i in range(times):\n com = input().split()\n if com[0] == "1":\n if revers == 0:\n revers = 1\n else :\n revers = 0\n \n else :\n if com[1] == "1":\n if revers == 0:\n head = com[2]+head\n else :\n tail = tail + com[2]\n else : \n if revers == 1:\n head = com[2]+head\n else :\n tail = tail + com[2] \nstr = head + str + tail\nif revers == 1:\n str = str[::-1]\n \nprint(str)'] | ['Runtime Error', 'Accepted'] | ['s499128043', 's593952413'] | [2940.0, 4428.0] | [18.0, 1483.0] | [620, 619] |
p02756 | u384793271 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["S = input()\nQ = int(input())\n\nrev = False\n\nfor i in range(Q):\n \n query = input().split()\n \n if query[0] == '1':\n if rev:\n rev = False\n else:\n rev = True\n else:\n \n F = query[1]\n \n if F == '1':\n \n if rev:\n \n S = S + query[2]\n \n else:\n \n S = query[2] + S\n する場合\n else:\n \n if rev:\n \n S = query[2] + S\n \n else:\n \n S = S + query[2]\nif rev:\n print(S[::-1])\nelse:\n print(S)", "S = input()\nQ = int(input())\n\nrev = False\n\nfor i in range(Q):\n \n query = input().split()\n \n if query[0] == '1':\n if rev == True:\n rev = False\n else:\n rev = True\n else:\n \n F = int(query[1])\n C = query[2]\n \n if F == 1:\n \n if rev == True:\n \n S = S + C\n \n else:\n \n S = C + S\n する場合\n else:\n \n if rev == True:\n \n S = C + S\n \n else:\n \n S = S + C\nif rev == True:\n print(S[::-1])\nelse:\n print(S)", "S = input()\nQ = int(input())\nQUERY = [input().split() for _ in range(Q)]\n\nrev = False\n\nfor query in QUERY:\n \n if query[0] == '1':\n if rev:\n rev = False\n else:\n rev = True\n else:\n \n if query[1] == '1':\n \n if rev:\n \n S = S + query[2]\n \n else:\n \n S = query[2] + S\n する場合\n else:\n \n if rev:\n \n S = query[2] + S\n \n else:\n \n S = S + query[2]\nif rev:\n print(S[::-1])\nelse:\n print(S)", "from collections import deque\n\nS = input()\nQ = int(input())\nQuery = [input().split() for _ in range(Q)]\n\nS = deque(S)\nrev = False\n\nfor TFC in Query:\n if TFC[0] == '1':\n rev = not rev\n else:\n if TFC[1] == '1':\n if rev:\n S.append(TFC[2])\n else:\n S.appendleft(TFC[2])\n else:\n if rev:\n S.appendleft(TFC[2])\n else:\n S.append(TFC[2])\nif rev:\n S.reverse()\nprint(''.join(S))"] | ['Time Limit Exceeded', 'Time Limit Exceeded', 'Time Limit Exceeded', 'Accepted'] | ['s012917426', 's242117973', 's699457710', 's122674057'] | [3840.0, 3836.0, 41676.0, 44788.0] | [2104.0, 2104.0, 2106.0, 429.0] | [966, 994, 909, 500] |
p02756 | u395816772 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ["import numpy as np\nS = input()\n\nQ = int(input())\n\nA = [S]\n\nfor i in range(Q):\n s = input().split()\n if len(s) == 1:\n A = A[::-1]\n else:\n if s[1] == '1':\n A.insert(0,s[2])\n else:\n A.insert(-1,s[2])\n\nprint('%s' % ''.join(A))\n\n", "Sr = list(input())\nSl = []\nQ = int(input())\n\n\nfor i in range(Q):\n s = list(input().split())\n if len(s) == 1:\n Sr,Sl = Sl,Sr\n else:\n if s[1] == '1':\n Sl.insert(0,s[2])\n else:\n Sr.append(s[2])\n\nprint('%s' % (''.join(Sl) + ''.join(Sr)))\n\n", "import numpy as np\nS = input()\n\nQ = int(input())\n\nA = [S]\n\nfor i in range(Q):\n s = input().split()\n if len(s) == 1:\n A = A[::-1]\n else:\n if s[1] == '1':\n A.insert(0,s[2])\n else:\n A.insert(-1,s[2])\n\nprint('%s' % ''.join(A))\n\n", "Sr = list(input())\nSl = []\nQ = int(input())\n\n\nfor i in range(Q):\n s = list(input().split())\n if len(s) == 1:\n Sr,Sl = Sl,Sr\n else:\n if s[1] == '1':\n Sl.append(s[2])\n else:\n Sr.append(s[2])\n\nprint('%s' % (''.join(Sl) + ''.join(Sr)))\n\n", "Sr = list(input())\nSl = []\nQ = int(input())\n\n\nfor i in range(Q):\n s = list(input().split())\n if len(s) == 1:\n Sr,Sl = Sl,Sr\n elif s[1] == '1':\n Sl.append(s[2])\n else:\n Sr.append(s[2])\nSl.reverse()\nprint('%s' % (''.join(Sl) + ''.join(Sr)))\n\n"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s674310071', 's738432239', 's762757163', 's819055078', 's564076000'] | [15616.0, 4764.0, 15796.0, 6296.0, 6292.0] | [2112.0, 2104.0, 2108.0, 497.0, 468.0] | [276, 287, 276, 285, 273] |
p02756 | u396210538 | 2,000 | 1,048,576 | Takahashi has a string S consisting of lowercase English letters. Starting with this string, he will produce a new one in the procedure given as follows. The procedure consists of Q operations. In Operation i (1 \leq i \leq Q), an integer T_i is provided, which means the following: * If T_i = 1: reverse the string S. * If T_i = 2: An integer F_i and a lowercase English letter C_i are additionally provided. * If F_i = 1 : Add C_i to the beginning of the string S. * If F_i = 2 : Add C_i to the end of the string S. Help Takahashi by finding the final string that results from the procedure. | ['from sys import stdin\nfrom collections import deque\n\nd = deque()\n\nS = stdin.readline().rstrip().split()\nQ = [int(x) for x in stdin.readline().rstrip().split()]\n\nd.append(S[0])\n# print(d)\nflag = 0b0\n\nfor i in range(Q[0]):\n s = input().split()\n\n if len(s) == 1:\n # print(len(d[0]))\n if len(d[0]) != 1:\n flag = ~flag\n # print(flag)\n \n # S=S[::-1]\n \n\n else:\n if int(s[1]) == 1:\n if flag == 0:\n d.appendleft(s[2])\n else:\n s[2] = s[2][::-1]\n # print(s[2])\n d.append(s[2])\n # print(d)\n \n # S.insert(0,s[2])\n\n else:\n if flag == 0:\n d.append(s[2])\n else:\n s[2] = s[2][::-1]\n # print(s[2])\n d.appendleft(s[2])\n \n # S.append(s[2])\n# print(flag)\nans = "".join(d)\n# print(ans)\nif flag == -1:\n ans = ans[::-1]\n \n # print(d)\n\n# print("".join(d))\nprint(ans)\n', 'from sys import stdin\n\nS = stdin.readline().rstrip().split()\nQ = [int(x) for x in stdin.readline().rstrip().split()]\n\nfor i in range(Q[0]):\n s=input().split()\n\n if len(s)==1:\n \n S=S[::-1]\n \n else:\n if int(s[1])==1:\n S.insert(0,s[2])\n \n\n else:\n S.append(s[2])\nfor i in range(len(S)):\n print(S[i],end="")', 'from sys import stdin\nfrom collections import deque\n\nd=deque()\n\nS = stdin.readline().rstrip().split()\nQ = [int(x) for x in stdin.readline().rstrip().split()]\n\nd.append(S[0])\n#print(d)\nfor i in range(Q[0]):\n s=input().split()\n\n if len(s)==1:\n\n #S=S[::-1]\n #print(d)\n d.reverse()\n #print(d)\n\n else:\n if int(s[1])==1:\n d.appendleft(s[2])\n #print(d)\n #S.insert(0,s[2])\n\n\n else:\n d.append(s[2])\n #print(d)\n #S.append(s[2])\nfor i in range(len(d)):\n print(d[i],end="")', 'from sys import stdin\nfrom collections import deque\n\nd = deque()\n\nS = stdin.readline().rstrip().split()\nQ = [int(x) for x in stdin.readline().rstrip().split()]\n\nd.append(S[0])\n# print(d)\nflag = 0b0\n\nfor i in range(Q[0]):\n s = input().split()\n\n if len(s) == 1:\n # print(len(d[0]))\n if len(d) == 1 and len(d[0]) == 1:\n pass\n else:\n flag = ~flag\n\n # if len(d[0])!=:\n \n # if len(d[0]) != 1:\n \n # print(flag)\n \n # S=S[::-1]\n \n\n else:\n if int(s[1]) == 1:\n if flag == 0:\n d.appendleft(s[2])\n else:\n s[2] = s[2][::-1]\n # print(s[2])\n d.append(s[2])\n # print(d)\n \n # S.insert(0,s[2])\n\n else:\n if flag == 0:\n d.append(s[2])\n else:\n s[2] = s[2][::-1]\n # print(s[2])\n d.appendleft(s[2])\n \n # S.append(s[2])\n# print(flag)\nans = "".join(d)\n# print(ans)\nif flag == -1:\n ans = ans[::-1]\n \n # print(d)\n\n# print("".join(d))\nprint(ans)\n'] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s158760440', 's207889676', 's511263401', 's818377861'] | [16552.0, 4928.0, 6900.0, 11756.0] | [551.0, 2104.0, 2104.0, 528.0] | [1130, 358, 549, 1295] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.