s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time int64 0 100 | memory stringlengths 4 6 | code_size int64 15 14.7k | code stringlengths 15 14.7k | problem_id stringlengths 6 6 | problem_description stringlengths 358 9.83k | input stringlengths 2 4.87k | output stringclasses 807
values | __index_level_0__ int64 1.1k 1.22M |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s012302192 | p01694 | u998188826 | 1443290736 | Python | Python3 | py | Accepted | 30 | 7620 | 204 |
p = [('ru','lu'), ('lu','ru'),('rd','ld'), ('ld','rd')]
while True:
n = int(input())
if n == 0:
break
l = False
r = False
f = input().split()
print(len([t for t in zip(f[1:], f[:-1]) if t in p])) | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,811 |
s222850963 | p01694 | u488601719 | 1452867000 | Python | Python | py | Accepted | 20 | 6396 | 678 | while True:
n = input()
if n == 0:
break
s = raw_input().split()
isLeftDown = True
isRightDown = True
isDown = True
cnt = 0
for i in range(n):
if s[i] == "lu":
isLeftDown = False
elif s[i] == "ld":
isLeftDown = True
elif s[i] ==... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,812 |
s184444847 | p01694 | u228002579 | 1461259600 | Python | Python | py | Accepted | 20 | 6344 | 388 | while True:
n = int(raw_input())
if n == 0: break
move = raw_input().split()
l,r,go,count = 0,0,1,0
for c in move:
if c == 'lu':
l = 1
if c == 'ru':
r = 1
if c == 'ld':
l = 0
if c == 'rd':
r = 0
if l == r and l =... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,813 |
s427956573 | p01694 | u685815919 | 1475046452 | Python | Python | py | Accepted | 20 | 6460 | 441 | while True:
n = int(raw_input())
if n == 0: break
s = raw_input().split()
state = [False, False]
counter = 0
stand = False
for step in s:
if step == "lu":
state[0] = True
elif step == "ru":
state[1] = True
elif step == "ld":
state[0] = False
elif step == "rd":
state... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,814 |
s722832993 | p01694 | u660912567 | 1481728393 | Python | Python3 | py | Accepted | 30 | 7392 | 297 | fn = {
'lu': lambda x,y: [1,y],
'ru': lambda x,y: [x,1],
'ld': lambda x,y: [0,y],
'rd': lambda x,y: [x,0]
}
while True:
if input()=='0': break
x,y = 0,0
c,f = 0,1
for s in input().split():
x,y = fn[s](x,y)
if x==y==f: c,f = c+1,abs(f-1)
print(c) | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,815 |
s341908686 | p01694 | u260980560 | 1483857919 | Python | Python | py | Accepted | 20 | 6340 | 439 | while 1:
n = input()
if n == 0:
break
F = raw_input().split()
mode = 1
s = [0,0]
ans = 0
for f in F:
if f[0]=="l":
s[0]^=1
if mode != s[0]:
mode = -1
else:
s[1]^=1
if mode != s[1]:
mode = ... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,816 |
s704740547 | p01694 | u078042885 | 1485543270 | Python | Python3 | py | Accepted | 30 | 7552 | 252 | while 1:
n=int(input())
if n==0:break
a=0
s=input().split()
for i in range(0,len(s),2):
if i+1==len(s):break
s[i]+=s[i+1]
if(('lu' in s[i] and 'ru' in s[i])or('ld' in s[i] and 'rd' in s[i])):a+=1
print(a) | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,817 |
s770856933 | p01694 | u078042885 | 1485609468 | Python | Python3 | py | Accepted | 30 | 7704 | 225 | while 1:
n=int(input())
if n==0:break
a=0
s=input().split()
for i in range(0,len(s)-1,2):
s[i]+=s[i+1]
if(('lu' in s[i] and 'ru' in s[i])or('ld' in s[i] and 'rd' in s[i])):a+=1
print(a) | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,818 |
s447391200 | p01694 | u724963150 | 1497160545 | Python | Python3 | py | Accepted | 30 | 7616 | 577 | while True:
n=int(input())
if n==0:break
_in=input().split(' ')
f_stat=[False,False] #[left,right]
state=False
cnt=0
for i in range(n):
com=_in[i]
if com=="lu":f_stat[0]=True
elif com=="ru":f_stat[1]=True
elif com=="ld":f_stat[0]=False
else:f_stat[1]=F... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,819 |
s856076349 | p01694 | u633333374 | 1502855596 | Python | Python | py | Accepted | 30 | 6388 | 547 | while 1:
n = int(input())
if n == 0:
break
a = b = c = sum = 0
lst = []
f = [str(x) for x in raw_input().split()]
for i in range(n):
if f[c] == 'lu':
a += 1
if f[c] == 'ld':
a -= 1
if f[c] == 'ru':
a += 1
if f[c] == 'rd'... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,820 |
s173247047 | p01694 | u741801763 | 1506345163 | Python | Python3 | py | Accepted | 40 | 7760 | 838 | if __name__ == "__main__":
while 1:
n = int(input())
if n == 0:break
line = input().strip().split()
lstate = 0 # floor = 0 ,upstairs = 1
rstate = 0
flag = 0#floor =0???????????°flag = 0
ans =0
for l in line:
if lstate and not flag and l == ... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,821 |
s970652213 | p01694 | u506554532 | 1513041636 | Python | Python3 | py | Accepted | 30 | 5612 | 372 | while True:
N = int(input())
if N == 0: break
src = list(input().split())
ru = lu = both = False
ans = 0
for f in src:
if f == 'ru': ru = True
elif f == 'lu': lu = True
elif f == 'rd': ru = False
else: lu = False
if ru == lu == (not both):
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,822 |
s313161883 | p01694 | u146816547 | 1524504733 | Python | Python | py | Accepted | 20 | 4652 | 422 | while True:
n = int(raw_input())
if n == 0:
break
f = raw_input().split()
ans = 0
for i in range(1, len(f)):
if f[i] == "lu" and f[i-1] == "ru":
ans += 1
elif f[i] == "ru" and f[i-1] == "lu":
ans += 1
elif f[i] == "ld" and f[i-1] == "rd":
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,823 |
s409758535 | p01694 | u023471147 | 1526609758 | Python | Python3 | py | Accepted | 30 | 5604 | 407 | while True:
n = int(input())
if n == 0:
break
step = list(input().split())
l = r = 0
ne = 1
cnt = 0
for mov in step:
if mov == "lu":
l = 1
elif mov == "ru":
r = 1
elif mov == "ld":
l = 0
else:
r = 0
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,824 |
s979966329 | p01694 | u509278866 | 1527832093 | Python | Python3 | py | Accepted | 60 | 9056 | 873 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**3
eps = 1.0 / 10**10
mod = 10**9+7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF():... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,825 |
s043537162 | p01694 | u922450532 | 1529057964 | Python | Python3 | py | Accepted | 30 | 5616 | 491 | while True:
c = 0
ans = 0
a = int(input())
left = 0
right = 0
if a == 0:
break
b = input()
b = b.split(" ")
for i in b:
if i == "lu":
left = 1
elif i == "ru":
right = 1
elif i == "rd":
right = 0
elif i == "ld... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,826 |
s453075242 | p01694 | u136916346 | 1530086721 | Python | Python3 | py | Accepted | 40 | 5612 | 496 | while 1:
n=int(input())
if not n:break
l=input().split()
pos=[0,0]
isdown=True
score=0
for i in l:
if i=="lu" and pos[0]==0:pos[0]+=1
elif i=="ru" and pos[1]==0:pos[1]+=1
elif i=="ld" and pos[0]>0:pos[0]-=1
elif i=="rd" and pos[1]>0:pos[1]-=1
if ... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,827 |
s743668221 | p01694 | u258535552 | 1530272608 | Python | Python3 | py | Accepted | 30 | 5580 | 657 | ansli=[]
while 1:
n=input()
if n=="0":
break
a=input().split()
up=0
down=1
lu=0
ru=0
ld=0
rd=0
count=0
for i in a:
if i=="ru":
ru=1
rd=0
elif i=="lu":
lu=1
ld=0
elif i=="rd":
rd=1
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,828 |
s947684318 | p01694 | u822573090 | 1530515297 | Python | Python3 | py | Accepted | 30 | 5572 | 349 | while(True):
n = input()
if n == '0': break
line = input()
qs = line.split(" ")
up = 0
down = 0
cnt = 0
for q in qs:
if q == "lu" or q == "ru" :
up += 1
down = 0
else:
down += 1
up = 0
if up==2 or down == 2:
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,829 |
s724871239 | p01694 | u057189799 | 1597276132 | Python | Python3 | py | Accepted | 30 | 5612 | 613 | while True:
n = int(input())
if n == 0:
break
f = list(input().split())
is_on = False
left_up = False
right_up = False
ans = 0
for i in range(n):
if f[i] == "lu":
left_up = True
elif f[i] == "ld":
left_up = False
elif f[i] == "... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,830 |
s700569308 | p01694 | u240091169 | 1594026202 | Python | Python3 | py | Accepted | 40 | 5616 | 591 | while True :
n = int(input())
if n == 0 :
break
posi = 0
right = 0
left = 0
cnt = 0
task = list(input().split())
for i in range(n) :
if task[i] == 'lu' :
left = 1
elif task[i] == 'ru' :
right = 1
elif task[i] == 'ld' :
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,831 |
s287169681 | p01694 | u965725118 | 1591791739 | Python | Python3 | py | Accepted | 30 | 5640 | 641 | def main():
N = int(input())
answer = []
while N != 0:
cmd = [i for i in input().split()]
ans = 0
g_flag = True
p = ["ld", "rd"]
for c in cmd:
if c[0] == "l":
p[0] = c
else:
p[1] = c
if g_flag and p[0... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,832 |
s982582549 | p01694 | u359849960 | 1591691255 | Python | Python3 | py | Accepted | 30 | 5612 | 440 | while True:
N = int(input())
if N == 0:
break
a = input()
b = a.split()
x = 0
for i in range(N//2):
if b[2 * i] == 'lu' and b[(2 * i)+1] == 'ru':
x += 1
if b[2 * i] == 'ru' and b[(2 * i)+1] == 'lu':
x += 1
if b[2 * i] == 'ld' and b[(2 * ... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,833 |
s551619695 | p01694 | u118403340 | 1591358642 | Python | Python3 | py | Accepted | 40 | 5620 | 506 | def identify(x:str, y:str):
if (x == "lu" and y == "ru") or (x == "ru" and y == "lu"):
return True
if (x == "ld" and y == "rd") or (x == "rd" and y == "ld"):
return True
while True:
num = int(input())
if num != 0:
udlr = input()
list_udlr = udlr.split()
count = 0... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,834 |
s389169332 | p01694 | u642694278 | 1589338070 | Python | Python3 | py | Accepted | 30 | 5620 | 444 | def solve(n):
ops = input().split()
states = [0 for i in range(n + 1)]
ans = 0
for i in range(n):
if ops[i] == "lu": states[i + 1] = states[i] + 1
elif ops[i] == "ru": states[i + 1] = states[i] + 2
elif ops[i] == "ld": states[i + 1] = states[i] - 1
else: states[i + 1] = states[i] - 2
if i >= 1 and (states... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,835 |
s111378453 | p01694 | u353888999 | 1586782155 | Python | Python3 | py | Accepted | 40 | 5608 | 417 | while 1:
n = int(input())
if n == 0:
break
f = list(map(str,input().split()))
cnt = 0
for i in range(n-1):
if f[i] == "lu" and f[i+1] == "ru":
cnt += 1
elif f[i] == "ru" and f[i+1] == "lu":
cnt += 1
elif f[i] == "ld" and f[i+1] == "rd":
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,836 |
s978619148 | p01694 | u206124123 | 1584242729 | Python | Python3 | py | Accepted | 30 | 5616 | 1,249 | DOWN = 0
UP = 1
MOVE_LIST = ["lu","ru","ld","rd"]
def get_input():
input_data = int(input())
return input_data
def get_data_list():
data_list = input().split()
return data_list
class Manager:
def __init__(self, move_num, record_list):
self.move_num = move_num
self.record_list = r... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,837 |
s212197942 | p01694 | u975129011 | 1580560054 | Python | Python3 | py | Accepted | 40 | 5612 | 470 | while 1:
n = int(input())
if n == 0:
break
f = list(map(str,input().split()))
cnt = 0
for i in range(n-1):
if (i+1) % 2 == 1:
if f[i] == "lu" and f[i+1] =="ru":
cnt += 1
if f[i] == "ru" and f[i+1] == "lu":
cnt += 1
i... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,838 |
s283450670 | p01694 | u829695570 | 1578808350 | Python | Python3 | py | Accepted | 30 | 5608 | 184 | while 1:
n = int(input())
if n==0: break
a = input().split()
cnt = 0
for i in range(n//2):
if a[2*i][0] != a[2*i+1][0]:
cnt += 1
print(cnt)
| p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,839 |
s159857739 | p01694 | u199911712 | 1571913304 | Python | Python3 | py | Accepted | 30 | 5680 | 286 | import math
while True:
answer = 0
count = int(input())
if count == 0: break
orders = input().split(' ')
for i in range(int(math.floor(count / 2))):
s = orders[ 2 * i: 2*i+2 ]
if not(s[0][0] == s[1][0]) and (s[0][1] == s[1][1]):
answer += 1
print(answer)
| p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,840 |
s983628980 | p01694 | u123563150 | 1571912602 | Python | Python3 | py | Accepted | 40 | 5616 | 306 | while True:
n=int(input())
if n==0:
break
a=list(map(str,input().split()))
cnt=0
l=r=0
q=0
for i in range(n):
if a[i]=="lu":
l=1
elif a[i]=="ru":
r=1
elif a[i]=="ld":
l=0
else:
r=0
if l==r==1 and q==0:
cnt+=1
q=1
elif l==r==0 and q==1:
cnt+=1
q=0
print(cnt)
| p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,841 |
s607013145 | p01694 | u479403716 | 1571910607 | Python | Python3 | py | Accepted | 30 | 5616 | 540 | while 1:
n = int(input())
if n == 0:
break
l = input().split()
lup, rup, up = False, False, False
res = 0
for s in l:
if s == 'lu':
lup = True
if s == 'ru':
rup = True
if s == 'ld':
lup = False
if s == 'rd':
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,842 |
s595430254 | p01694 | u048191691 | 1571910588 | Python | Python3 | py | Accepted | 30 | 5608 | 412 |
while True:
N = int(input())
if N == 0:
break
a = list(input().split())
l = 0
r = 0
las = 0
ans = 0
for i in a:
if i == "lu":
l += 1
elif i == "ld":
l -= 1
elif i == "ru":
r += 1
else:
r -= 1
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,843 |
s233808477 | p01694 | u245823788 | 1562849848 | Python | Python3 | py | Accepted | 30 | 5612 | 552 | while True:
n = int(input())
if n==0:
break
f = list(input().split())
cnt = 0
rf = 0
lf = 0
foot = 0
for i in range(n):
if lf==0 and f[i]=="lu":
lf = 1
elif rf==0 and f[i]=="ru":
rf = 1
if foot==0 and lf==1 and rf==1:
c... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,844 |
s781284431 | p01694 | u340991036 | 1562833729 | Python | Python3 | py | Accepted | 40 | 5612 | 552 | while True:
n = int(input())
if n==0:
break
f = list(input().split())
cnt = 0
rf = 0
lf = 0
foot = 0
for i in range(n):
if lf==0 and f[i]=="lu":
lf = 1
elif rf==0 and f[i]=="ru":
rf = 1
if foot==0 and lf==1 and rf==1:
c... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,845 |
s715922403 | p01694 | u529214876 | 1562579553 | Python | Python3 | py | Accepted | 30 | 5628 | 411 | ans_list = []
while True:
n = int(input())
if n == 0:
break
S = input().split()
cnt = 0
dq = []
for s in S:
if not dq:
dq.append(s)
if [dq[-1], s] in [["lu","ru"],["ru","lu"],["ld","rd"],["rd","ld"]]:
cnt += 1
dq.append("@")
el... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,846 |
s672881026 | p01694 | u200148444 | 1562578962 | Python | Python3 | py | Accepted | 40 | 5612 | 414 | while True:
n=int(input())
if n==0:exit()
l0=list(map(str,input().split()))
ans=0
l=0
r=0
k=1
for x in l0:
if x=="lu":
l=1
elif x=="ld":
l=0
elif x=="ru":
r=1
else:
r=0
if k+l+r==3:
ans+=1... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,847 |
s123164863 | p01694 | u135085051 | 1561710795 | Python | Python3 | py | Accepted | 40 | 5628 | 675 | ans = []
while True:
n = int(input())
if n == 0:
break
l_step, r_step = 0, 0
flag = False
step = input().split()
cnt = 0
for i in range(n):
if step[i] == "lu":
l_step = 1
elif step[i] == "ru":
r_step = 1
elif step[i] ==... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,848 |
s980179594 | p01694 | u037441960 | 1561030768 | Python | Python3 | py | Accepted | 40 | 5624 | 287 | Set = [("lu", "ru"), ("ru","lu"), ("ld","rd"), ("rd","ld")]
while True :
n = int(input())
if(n == 0) :
break
else :
F = list(map(str, input().split()))
cnt = 0
while(len(F) > 1) :
if((F[0], F[1]) in Set) :
cnt += 1
del F[0 : 2]
else :
del F[0]
print(cnt)
| p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,849 |
s598077690 | p01694 | u489876484 | 1560417658 | Python | Python3 | py | Accepted | 20 | 5612 | 564 | def main():
while True:
n = int(input())
if not n:
return
ls = False
rs = False
ns = True
c = 0
for f in input().split():
if f == "lu":
ls = True
elif f == "ru":
rs = True
elif f =... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,850 |
s643873873 | p01694 | u990228206 | 1553080183 | Python | Python3 | py | Accepted | 40 | 5608 | 426 | while 1:
n=int(input())
if n==0:break
now=0
ans=0
l=0
r=0
mt=list(map(str,input().split()))
for i in mt:
if i=="lu":l=1
elif i=="ru":r=1
elif i=="ld":l=0
elif i=="rd":r=0
if now==0:
if l+r==2:
ans+=1
now=... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,851 |
s310479657 | p01694 | u717526540 | 1545024526 | Python | Python3 | py | Accepted | 40 | 5620 | 885 | while 1:
n = int(input())
if n == 0:
break
step = list(input().split())
pos = 0 # 0:bottom, 1:top
lu, ru, ld, rd = [0] * 4
cnt = 0
for s in step:
if pos == 0:
if s == "lu":
lu = 1
elif s == "ru":
ru = 1
... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,852 |
s345883086 | p01694 | u281836941 | 1513659167 | Python | Python3 | py | Accepted | 30 | 5624 | 678 | # coding: utf-8
def q1():
while 1:
count=0
n=int(input())
if(n==0):
break
data=input().split()
f=False
ft=[False,False]
for order in data:
if order[0]=='l':
x=0
else:
x=1
if order[... | p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,853 |
s190583543 | p01694 | u717727327 | 1421080056 | Python | Python | py | Accepted | 20 | 4200 | 242 | def solve(f):
cnt = 0
for i in range(len(f)-1):
if f[i][1] == f[i+1][1]:
cnt += 1
return cnt
while True:
n = int(raw_input())
if n == 0:
break
f = raw_input().split(" ")
print solve(f)
| p01694 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | 4
lu ru ld rd
4
lu ld lu ru
1
lu
10
ru lu ld rd ru rd ru lu rd ld
0
| 2
1
0
4
| 26,854 |
s443551196 | p01696 | u144532944 | 1531424310 | Python | Python3 | py | Accepted | 50 | 6520 | 401 | import re
bracket = re.compile(r'\[([\w?+-]+)\]')
incr = re.compile(r'([+-]*)([\w?])')
def f(s, c):
if c == '?': return 'A'
return chr(ord('A')+(ord(c)-ord('A')+s.count('+')-s.count('-'))%26)
while True:
s = input().strip()
if s == '.': break
s = incr.sub(lambda m: f(*m.group(1, 2)), s)
while... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,855 |
s407652522 | p01696 | u509278866 | 1535352804 | Python | Python3 | py | Accepted | 70 | 9096 | 2,469 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,856 |
s712593519 | p01696 | u144532944 | 1546295445 | Python | Python3 | py | Accepted | 60 | 6516 | 617 | import re
bra_re = re.compile(r'\[([-+\w?]+)\]')
let_re = re.compile(r'[-+]*[\w?]')
def rep(m):
s = m.group(0)
if s[-1] == '?': return 'A'
d = 0
d += s.count('+')
d -= s.count('-')
d %= 26
d += ord(s[-1])
if d < ord('A'): d += 26
if d > ord('Z'): d -= 26
return chr(d)
def dec(... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,857 |
s779172924 | p01696 | u749493116 | 1452529740 | Python | Python | py | Accepted | 40 | 6472 | 1,118 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
let = [chr(i) for i in xrange(ord('A'), ord('Z') + 1)]
def reverse(s, pos):
res, rev = "", ""
p = 0
while p < len(s):
if s[p] == '[':
hoge, p = reverse(s[p + 1:], p + 1)
rev += hoge
elif s[p] == ']':
return re... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,858 |
s955948413 | p01696 | u269391636 | 1523773573 | Python | Python3 | py | Accepted | 60 | 5584 | 1,086 | alps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def reverse(data):
ret = ""
while(True):
if data[0] == "[" and (not ("[" in data[1:]) or data.index("[") > data.index("]")):
tmp = data[1:data.index("]")][::-1]
ret += tmp
ret += data[data.index("]")+1:]
return(ret)
... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,859 |
s021933741 | p01696 | u598814210 | 1529060319 | Python | Python3 | py | Accepted | 30 | 5568 | 833 | pos = 0
s = ""
def read():
global pos
global s
result = ""
ruiseki = 0
while pos < len(s):
if s[pos] == '+':
ruiseki += 1
elif s[pos] == '-':
ruiseki -= 1
elif s[pos] == '[':
pos += 1
result += read()
pos -= 1
... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,860 |
s925158458 | p01696 | u467175809 | 1529680471 | Python | Python | py | Accepted | 30 | 5128 | 1,421 | #!/usr/bin/env python
from collections import deque
import itertools as it
import sys
sys.setrecursionlimit(1000000)
def rev(S):
return S[::-1]
def add(S):
if S[0] == '?':
return S
lst = list(S)
lst[0] = chr((ord(S[0]) - ord('A') + 1) % 26 + ord('A'))
return ''.join(lst)
def dec(S):
... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,861 |
s934401932 | p01696 | u591052358 | 1530078461 | Python | Python3 | py | Accepted | 30 | 5580 | 1,264 | def c_to_int(char):
return ord(char)-65
def solve(s):
count = 0
table=[]
for str in s:
if str=='+':
count +=1
elif str =='-':
count -=1
elif str=='[':
table.append(str)
elif str==']':
table.append(str)
elif str=='?'... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,862 |
s277459714 | p01696 | u731941832 | 1530610054 | Python | Python3 | py | Accepted | 30 | 5572 | 985 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:
break
e = s[index:].find(']')
s = s[:index] + s[index + 1:index + e][::-1] + s[index + e + 1:]
... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,863 |
s488438106 | p01696 | u731941832 | 1530612305 | Python | Python3 | py | Accepted | 30 | 5580 | 815 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index, len(s))
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index ... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,864 |
s246170783 | p01696 | u731941832 | 1530612345 | Python | Python3 | py | Accepted | 30 | 5576 | 807 | while True:
s = input()
if s == '.':break
while True:
if s.find('+') == -1 and s.find('-') == -1:
index = s.rfind('[')
if index == -1:break
e = s.find(']', index)
s = s[:index] + s[index + 1:e][::-1] + s[e + 1:]
else:
index = s.find... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,865 |
s530671015 | p01696 | u528682978 | 1597577551 | Python | Python3 | py | Accepted | 50 | 6524 | 431 | def pm_to_chr(s):
s=s.group()
if s[-1]=='?':
return 'A'
ans=chr((((ord(s[-1])+s.count('+')-s.count('-'))-ord('A'))%26)+ord('A'))
return ans
def reverse(s):
s=s.group()
s=s[1:-1]
ans=''.join(reversed(s))
return ans
import re
s=input()
while s!='.':
s=re.sub("[\+\-]*[\w?]",p... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,866 |
s574972878 | p01696 | u616775713 | 1562321394 | Python | Python3 | py | Accepted | 80 | 6692 | 1,658 | import string
dic_str = {}
for i,item in enumerate(string.ascii_uppercase):
dic_str[item] = i
"""
def rev(lis,bl = False):
if not "[" in lis:
return "".join(lis)
else:
start = -1
end = -1
i = 0
while(i < len(lis)):
if (start == -1) and (lis[i] == "["):
start = i
if (start !... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,867 |
s237529170 | p01696 | u245823788 | 1560385257 | Python | Python3 | py | Accepted | 40 | 6680 | 508 | import string
abc = string.ascii_uppercase
while True:
s = input()
if s==".":
break
num = 0
rev = 0
nest = ["" for i in range(80)]
for e in s:
if e=="+":
num += 1
elif e=="-":
num -= 1
elif e=="[":
rev += 1
elif e=="]":
t = nest[rev]
nest[rev-1] += t[::-1... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,868 |
s722243663 | p01696 | u990228206 | 1553082995 | Python | Python3 | py | Accepted | 50 | 6508 | 796 | import re
while 1:
s=input()
if s==".":break
while "+-" in s or "-+" in s:
s=s.replace("+-","").replace("-+","")
while "+" in s:
pos=s.rfind("+")
cha=s[pos]+s[pos+1]
if ord(s[pos+1])==90:cha_r="A"
elif ord(s[pos+1])==63:cha_r="?"
else:cha_r=chr(ord(s[pos+1... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,869 |
s478712106 | p01696 | u281836941 | 1515053877 | Python | Python3 | py | Accepted | 40 | 5584 | 1,182 | def make(s):
d=[]
i=0
ans=''
while i<len(s):
if s[len(s)-i-1] not in '+-[]':
d.append(ord(s[len(s)-i-1]))
else:
if s[len(s)-i-1] == '+':
if d[-1]!=ord('?'):
d[-1]=((d[-1]+1)-ord('A'))%26+ord('A')
elif s[len(s)-i-1] =... | p01696 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<!-- begin en only -->
<!--<h3... | A+A++A
Z-Z--Z+-Z
[ESREVER]
J---?---J
++++++++A+++Z-----------A+++Z
[[++-+--?[--++-?++-+++L]][-+-----+-O]]++++---+L
.
| ABC
ZYXZ
REVERSE
JAG
ICPC
JAPAN
| 26,870 |
s301972211 | p01701 | u827448139 | 1418306933 | Python | Python3 | py | Accepted | 70 | 14756 | 273 | from fractions import Fraction
while True:
s=input()
if s=="#": break
s="".join([c for c in s if c=='n' or c=='w'])
x=0 if s[-1]=='n' else 90
for i in range(len(s)-1):
if s[-2-i]=='n':
x-=Fraction(45,1<<i)
else:
x+=Fraction(45,1<<i)
print(x) | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,871 |
s908728987 | p01701 | u617183767 | 1421854391 | Python | Python | py | Accepted | 20 | 4672 | 1,371 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
import os
import sys
import itertools
import math
from collections import Counter, defaultdict
class Main(object):
def __init__(self):
pass
def solve(self):
'''
insert your code
'''
while True:
s = raw_inp... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,872 |
s355896338 | p01701 | u633068244 | 1421856427 | Python | Python | py | Accepted | 10 | 4228 | 365 | while 1:
s = raw_input().replace("north","0").replace("west","1")
if s == "#": break
u = 90*int(s[-1])
d = 1
s = s[:-1]
while s:
if s[-1] == "0": u = 2*u-90
elif s[-1] == "1": u = 2*u+90
d *= 2
s = s[:-1]
while u%2 == 0 and d > 1:
u /= 2
d ... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,873 |
s441345521 | p01701 | u633068244 | 1421856620 | Python | Python | py | Accepted | 10 | 4224 | 331 | while 1:
s = raw_input().replace("north","0").replace("west","1")
if s == "#": break
u = 90*int(s[-1])
d = 1
s = s[:-1]
while s:
u *= 2; d *= 2
u += 90 if s[-1] == "1" else -90
s = s[:-1]
while u%2 == 0 and d > 1:
u /= 2; d /= 2
print u if d == 1 else "%... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,874 |
s870424672 | p01701 | u633068244 | 1421857223 | Python | Python | py | Accepted | 10 | 4220 | 303 | while 1:
s = raw_input().replace("north","0").replace("west","1")[::-1]
if s == "#": break
u = 90*int(s[0])
s = s[1:]
d = 2**len(s)
for i in s:
u = 2*u+(90 if i == "1" else -90)
while u%2 == 0 and d > 1:
u /= 2; d /= 2
print u if d == 1 else "%d/%d"%(u,d) | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,875 |
s383834635 | p01701 | u633068244 | 1421857604 | Python | Python | py | Accepted | 20 | 4220 | 270 | while 1:
s = raw_input().replace("north","0").replace("west","1")[::-1]
if s == "#": break
u = 90*int(s[0])
d = len(s)-1
for i in s[1:]: u = 2*u+(90 if i == "1" else -90)
while (u+1)%2*d: u /= 2; d -= 1
print u if d == 0 else "%d/%d"%(u,2**d) | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,876 |
s867863912 | p01701 | u316268279 | 1422036328 | Python | Python3 | py | Accepted | 30 | 6716 | 735 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
while True:
direction = ''.join(reversed(input()))
if direction == '#':
break
count = 0
ans = 0
while direction != '':
if direction[0] == 'h':
if count == 0:
ans = 0
else:
ans = an... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,877 |
s604680853 | p01701 | u731235119 | 1422171116 | Python | Python | py | Accepted | 20 | 4252 | 526 | while 1:
s = raw_input()
if s == "#":
break
length = len(s)
l = list()
num = -1
i = 0
while i < length :
if s[i:i+4] == "west":
l.append("w")
i += 4
else:
l.append("n")
i += 5
num += 1
l = l[::-1]
direction = 90 * (2**num) if l[0] == "w" else 0
for i in range(1,num+1):
if l[i] == "w":
... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,878 |
s396439620 | p01701 | u120360464 | 1423564120 | Python | Python | py | Accepted | 10 | 4288 | 933 | #! /usr/bin/python
# -*- coding: utf-8 -*-
def reduction(num, denom):
p = num
q = denom
while p%q != 0:
r = p%q
p = q
q = r
return [num/q, denom/q]
d = raw_input()
while d != "#":
l = 0
direc = []
while l < len(d):
if d[l] == 'n':
direc.append('n... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,879 |
s410548117 | p01701 | u408260374 | 1446094312 | Python | Python3 | py | Accepted | 60 | 10092 | 438 | from fractions import Fraction
while True:
s = input()
if s == '#':
break
if s[-4:] == 'west':
ans = Fraction(90)
s = s[:-4]
else:
ans = Fraction(0)
s = s[:-5]
i = 1
while s:
if s[-4:] == 'west':
ans += Fraction(90, 1 << i)
... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,880 |
s353004540 | p01701 | u408260374 | 1446094661 | Python | Python3 | py | Accepted | 70 | 10084 | 433 | from fractions import Fraction
while True:
s = input()
if s == '#':
break
N = len(s)
if s[-1] == 't':
ans = Fraction(90)
p = 4
else:
ans = Fraction(0)
p = 5
i = 1
while p < N:
if s[-1-p] == 't':
ans += Fraction(90, 1 << i)
... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,881 |
s867652315 | p01701 | u220324665 | 1475311380 | Python | Python3 | py | Accepted | 60 | 10068 | 295 | from fractions import *
while True:
s=input()[::-1]
if s=='#':break
if s[0]=='h':
angle=Fraction(0)
cnt=5
else:
angle=Fraction(90)
cnt=4
i=1
while cnt<len(s):
if s[cnt]=='h':
angle-=Fraction(90/2**i)
cnt+=5
else:
angle+=Fraction(90/2**i)
cnt+=4
i+=1
print(angle) | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,882 |
s830931191 | p01701 | u078042885 | 1487343668 | Python | Python3 | py | Accepted | 30 | 7600 | 292 | import re
while 1:
s=input()
if s=='#':break
s=re.split('[w|n]',s)[1:];c=1
d=90 if s[-1]=='est' else 0
for x in s[:-1][::-1]:
d*=2
d+=90if x=='est'else-90
c*=2
while d&1==0 and c&1==0:d//=2;c//=2
if c==1:print(d)
else:print(d,c,sep='/') | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,883 |
s626035511 | p01701 | u728992264 | 1491831862 | Python | Python3 | py | Accepted | 50 | 9916 | 415 | from fractions import Fraction
def rec(s):
if s[0] == 'n':
if len(s) > 5:
t = rec(s[5:])
return [(t[0] - 45) * 2, t[1] + 1]
else:
return [0, 0]
else:
if len(s) > 4:
t = rec(s[4:])
return [(t[0] + 45) * 2, t[1] + 1]
else:
return [90, 0]
while True:
s = input()... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,884 |
s486438191 | p01701 | u506554532 | 1513568895 | Python | Python3 | py | Accepted | 50 | 6840 | 508 | from fractions import Fraction
def calc(s):
n = ans = 0
while len(s) >= 4:
if s[-4] == 'w':
s = s[:-4]
if n == 0:
ans = Fraction(90,1)
else:
ans += Fraction(90, 2**n)
else:
s = s[:-5]
if n == 0:
... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,885 |
s981806111 | p01701 | u023471147 | 1527159685 | Python | Python3 | py | Accepted | 30 | 5628 | 535 | from math import gcd
while True:
s = str(input())
if s == "#":
break
li = list()
while s:
if s[:5] == "north":
li.append(-1)
s = s[5:]
else:
li.append(1)
s = s[4:]
ans = li[-1] * 45 + 45
li = li[:-1]
mot = 1
f... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,886 |
s100705902 | p01701 | u509278866 | 1528105940 | Python | Python3 | py | Accepted | 50 | 9044 | 1,399 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF... | p01701 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | north
west
northwest
northnorthwest
westwestwestnorth
#
| 0
90
45
45/2
315/4
| 26,887 |
s900312032 | p01708 | u260980560 | 1586184336 | Python | Python3 | py | Accepted | 30 | 5672 | 2,271 | digits = "-0123456789"
def cross_point(P, Q):
x0, y0, x1, y1 = P
x2, y2, x3, y3 = Q
dx0 = x1 - x0; dy0 = y1 - y0
dx1 = x3 - x2; dy1 = y3 - y2
s = (y0-y2)*dx1 - (x0-x2)*dy1
sm = dx0*dy1 - dy0*dx1
if s < 0:
s = -s
sm = -sm
if s == 0:
x = x0
y = y0
else:... | p01708 |
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});
</script>
<script language="JavaScript" type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>
<meta http-equiv="X-UA-Compatibl... | ((0,0)@(1,1))@((4,1)@(2,5))
((0,0)@(3,1))@((1,-3)@(2,-1))
(0,0)@(1,1)@(4,1)
(0,0)@((1,1)@(4,1))
(((0,0)@((10,20)@(((30,40))))))
((0,0)@(3,1))@((1,-3)@(2,-1))@(100,-100)@(100,100)
#
| 3.00000000 3.00000000
3.00000000 1.00000000
1.00000000 4.00000000
0.00000000 2.00000000
-10.00000000 10.00000000
-99.83681795 -91.92248853
| 26,888 |
s906976575 | p01722 | u046108504 | 1559577205 | Python | Python3 | py | Accepted | 20 | 5592 | 113 | n = int(input())
if n == 0:
print(1)
elif n == 1:
print(2)
elif n == 2:
print(1)
else:
print(0)
| p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,889 |
s261702332 | p01722 | u408260374 | 1429527423 | Python | Python3 | py | Accepted | 40 | 6728 | 111 | n = int(input())
if n == 0:
print(1)
elif n == 1:
print(2)
elif n == 2:
print(1)
else:
print(0) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,890 |
s730245441 | p01722 | u633068244 | 1433093974 | Python | Python | py | Accepted | 20 | 4188 | 73 | n = int(raw_input())
if n == 1: print 2
elif n < 3: print 1
else: print 0 | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,891 |
s242536365 | p01722 | u434428594 | 1440143883 | Python | Python3 | py | Accepted | 50 | 7716 | 802 | # p(n) = 2^^n より大きい最小の素数 (ただし^^はクヌースの二重矢印記号) と定義したとき、
# x = (10^(p(n)-1)-1)/9 (mod p(n)) を求めよ
# 「フェルマーの小定理」
# pが素数ならば、a^p == a (mod p(n))
# とくに、aとpが互いに素 (gcd(a,p)=1) のとき
# a^p * a^-1 == a * a^-1 (mod p(n))
# a^(p-1) == 1 (mod p)
#
# 9とp(n)が互いに素ならば
# x * 9^-1 = 10^(p(n)-1)-1 (mod p(n))
# 10とp(n)が互いに素ならば
# 10^(p(n)-1) = ... | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,892 |
s372528074 | p01722 | u886766186 | 1475307065 | Python | Python3 | py | Accepted | 30 | 7644 | 96 | n = int(input())
if n == 0 or n == 2:
print(1)
elif n == 1:
print(2)
else:
print(0) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,893 |
s276934899 | p01722 | u078042885 | 1483681272 | Python | Python3 | py | Accepted | 20 | 7668 | 69 | n=int(input())
if n==0 or n==2:print(1)
else: print(2 if n==1 else 0) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,894 |
s442189520 | p01722 | u078042885 | 1487407812 | Python | Python3 | py | Accepted | 20 | 7660 | 45 | n=int(input())
if n>3:n=3
print([1,2,1,0][n]) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,895 |
s107550453 | p01722 | u078042885 | 1487408237 | Python | Python3 | py | Accepted | 20 | 7676 | 43 | n=int(input())
print([1,2,1,0][[n,3][n>3]]) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,896 |
s811545316 | p01722 | u078042885 | 1487408643 | Python | Python3 | py | Accepted | 30 | 7656 | 39 | n=int(input())
print(1if n==0else 2//n) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,897 |
s793390343 | p01722 | u078042885 | 1487414857 | Python | Python3 | py | Accepted | 20 | 7656 | 39 | n=int(input())
print(1if n==0else 2//n) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,898 |
s782523697 | p01722 | u709185111 | 1491030806 | Python | Python3 | py | Accepted | 20 | 7668 | 89 | n = int(input())
if n==0 or n==2:
print(1)
elif n==1:
print(2)
else:
print(0) | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,899 |
s751528869 | p01722 | u509278866 | 1528690001 | Python | Python3 | py | Accepted | 60 | 9024 | 919 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]
def LI(): return [int(x) for x in sys.stdi... | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,900 |
s290491620 | p01722 | u847467233 | 1530360736 | Python | Python3 | py | Accepted | 20 | 5596 | 119 | # AOJ 2610: Fast Division
# Python3 2018.6.30 bal4u
ans = [1, 2, 1, 0]
n = int(input())
if n > 2: n = 3
print(ans[n])
| p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,901 |
s823781501 | p01722 | u003684951 | 1564925779 | Python | Python3 | py | Accepted | 20 | 5584 | 98 | n = int(input())
if n == 0 or n == 2:
print(1)
elif n == 1:
print(2)
else:
print(0)
| p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,902 |
s846803019 | p01722 | u409173468 | 1561788994 | Python | Python3 | py | Accepted | 20 | 5584 | 94 | n=int(input())
if n == 0 or n == 2:
print(1)
elif n == 1:
print(2)
else:
print(0)
| p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,903 |
s829089691 | p01722 | u853158149 | 1555663323 | Python | Python3 | py | Accepted | 40 | 8248 | 1,946 | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.... | p01722 |
<p>
イクタ君は速いプログラムが大好きである。最近は、除算のプログラムを高速にしようとしている。しかしなかなか速くならないので、「常識的に考えて典型的」な入力に対してのみ高速にすればよいと考えた。イクタ君が解こうとしている問題は次のようなものである。
</p>
<p>
与えられた非負整数<var>n</var>に対し、10進法で<var>p(n) − 1</var>桁の正整数<var>11</var>...<var>1</var>を<var>p(n)</var>で割ったあまりを求めよ。ただし<var>p(n)</var>は<var>2<sup>2<sup>{</sup> . . . <sup>2</sup><... | 0
| 1
| 26,904 |
s149183466 | p01725 | u467175809 | 1531414227 | Python | Python | py | Accepted | 20 | 5072 | 1,213 | #!/usr/bin/env python
import sys
import math
import itertools as it
from collections import deque
sys.setrecursionlimit(10000000)
def calc(lst, pos, pr):
ret = []
while pos < len(lst):
if lst[pos] == '(':
val, pos = calc(lst, pos + 1, pr)
ret.append(val)
elif lst[pos] ... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,905 |
s545767253 | p01725 | u509278866 | 1534825912 | Python | Python3 | py | Accepted | 60 | 9044 | 2,278 | import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
def LI(): return [int(x) for x in sys.stdin.... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,906 |
s741847693 | p01725 | u260980560 | 1507975304 | Python | Python3 | py | Accepted | 70 | 8380 | 1,072 | from string import digits
from itertools import product
S = input() + "$"
def parse(pri):
code = "+-*"
cur = 0
def number():
nonlocal cur
c = S[cur]
if c == '(':
cur += 1 # '('
v = expr(0)
cur += 1 # ')'
return v
num = 0
... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,907 |
s437997149 | p01725 | u352394527 | 1529813904 | Python | Python3 | py | Accepted | 20 | 5628 | 1,766 | INF = 10 ** 20
ops = ["+", "-", "*"]
nums = [str(i) for i in range(0, 10)]
priorities = []
for op1 in ops:
for op2 in ops:
for op3 in ops:
if op1 != op2 and op1 != op3 and op2 != op3:
priorities.append([[op1], [op2], [op3]])
priorities.append([[op1], [op2, op3]])
priorities.append([[... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,908 |
s037480942 | p01725 | u855199458 | 1530530596 | Python | Python3 | py | Accepted | 30 | 5876 | 1,410 | # -*- coding: utf-8 -*-
from itertools import product
def parse(S, op):
"""
構文木を返す
Sは普通の記法の式
opは優先順序 通常は(*/: 1, +-: 2)
"""
S = "0+({})".format(S)
V = []
for x in list("()+-*"):
S = S.replace(x, " {} ".format(x))
i = 0
rank = 0
O = []
for s in S.split():
i... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,909 |
s562314742 | p01725 | u855199458 | 1530581734 | Python | Python3 | py | Accepted | 30 | 5692 | 997 | from itertools import product
S = input()
for x in "()+*-":
S = S.replace(x, " {} ".format(x))
S = S.split()
def parse(pri, cur):
def number():
nonlocal cur
if S[cur].isdigit():
val = int(S[cur])
cur += 1
return val
cur += 1
val = expr(0)
... | p01725 |
<p>小学生のイクタ君は、ある日おじいさんから数式が書かれた紙をもらった。
どうやらおじいさんは数式の答えの金額だけお小遣いをくれるらしい。
イクタ君はまだ足し算、引き算、掛け算しか習ってなかったので、数式にも足し算と引き算と掛け算しか使われていない。
通常の計算では足し算と引き算より掛け算を先に計算しなければならないのだが、イクタ君は演算子の優先順位についての理解があやふやだったので、とりあえず数式の計算結果が最大になるような都合の良い優先順位を考えることにした。
</p>
<p><var>+−×</var>の3つの二項演算子と括弧を含む数式が与えられる。
3つの演算子の優先順位を任意に変更して、数... | 3-2*3
| 3
| 26,910 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.