s_id string | p_id string | u_id string | date string | language string | original_language string | filename_ext string | status string | cpu_time string | memory string | code_size string | code string | error string | stdout string |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s172457248 | p00129 | u912237403 | 1415501658 | Python | Python | py | Runtime Error | 0 | 0 | 825 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1 # 両方壁の中
elif F==[1,0] or F==[0,1]: c=0 # 片方が壁の中
elif F==[0,0]: #両方壁の外
a=M.pi/2-M.acos(r/rsw)
tmp=(sw[0]*st[0]+sw[1]*st[1])/rsw/rst
if abs(abs(tmp)-1)<1e-6: tmp=1
b=M.acos(tmp)
if C(a,b) and C(rst**2,rsw**2-r**2): c=0
else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmpcp1amiex/tmp1zs3_m8s.py", line 28, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s127327844 | p00129 | u912237403 | 1415501803 | Python | Python | py | Runtime Error | 0 | 0 | 827 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1 # 両方壁の中
elif F==[1,0] or F==[0,1]: c=0 # 片方が壁の中
elif F==[0,0]: #両方壁の外
a=M.pi/2-M.acos(r/rsw)
tmp=(sw[0]*st[0]+sw[1]*st[1])/rsw/rst
if abs(abs(tmp)-1)<1e-6: tmp=1
b=M.acos(tmp/2)
if C(a,b) and C(rst**2,rsw**2-r**2): c=0
else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmp8h2nf_g1/tmp8yizqtft.py", line 28, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s820801747 | p00129 | u912237403 | 1415501831 | Python | Python | py | Runtime Error | 0 | 0 | 829 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1 # 両方壁の中
elif F==[1,0] or F==[0,1]: c=0 # 片方が壁の中
elif F==[0,0]: #両方壁の外
a=M.pi/2-M.acos(r/rsw)
tmp=(sw[0]*st[0]+sw[1]*st[1])/rsw/rst
if abs(abs(tmp)-1)<1e-6: tmp=1
b=0#M.acos(tmp/2)
if C(a,b) and C(rst**2,rsw**2-r**2): c=0
else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmp8cjsja70/tmp1wquf4kf.py", line 28, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s052008815 | p00129 | u912237403 | 1415501857 | Python | Python | py | Runtime Error | 0 | 0 | 831 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1 # 両方壁の中
elif F==[1,0] or F==[0,1]: c=0 # 片方が壁の中
elif F==[0,0]: #両方壁の外
a=M.pi/2-M.acos(r/rsw)
tmp=0#(sw[0]*st[0]+sw[1]*st[1])/rsw/rst
if abs(abs(tmp)-1)<1e-6: tmp=1
b=0#M.acos(tmp/2)
if C(a,b) and C(rst**2,rsw**2-r**2): c=0
else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmp2loqbr9r/tmpirdzr8rd.py", line 28, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s811566908 | p00129 | u912237403 | 1415501894 | Python | Python | py | Runtime Error | 0 | 0 | 835 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1 # 両方壁の中
elif F==[1,0] or F==[0,1]: c=0 # 片方が壁の中
elif F==[0,0]: #両方壁の外
a=M.pi/2-M.acos(r/rsw)
#tmp=0#(sw[0]*st[0]+sw[1]*st[1])/rsw/rst
#if abs(abs(tmp)-1)<1e-6: tmp=1
b=0#M.acos(tmp/2)
#if C(a,b) and C(rst**2,rsw**2-r**2): c=0
#else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmpylf8erx1/tmp16q030wa.py", line 28, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s012979036 | p00129 | u912237403 | 1415501987 | Python | Python | py | Runtime Error | 0 | 0 | 730 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
tx,ty,sx,sy=e1
x=[]
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
st=[tx-sx,ty-sy]; rst=R(st)
F=[rwt<r,rsw<r]
if rst==0: c=1
elif F==[1,1]: c=1
elif F==[1,0] or F==[0,1]: c=0
elif F==[0,0]:
c=0
a=M.pi/2-M.acos(r/rsw)
b=M.acos((sw[0]*st[0]+sw[1]*st[1])/rsw/rst)
# if C(a,b) and C(rst**2,rsw**2-r**2): c=0
# else: c=1
x.append(c)
return all(x)
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmpfd_510qq/tmprwjzipb7.py", line 27, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s628153279 | p00129 | u873482706 | 1435892993 | Python | Python | py | Runtime Error | 0 | 0 | 763 | import math
def f():
x = 0; y = 1; r = 2
for w in L_w:
A = (tx-w[x])**2 + (ty-w[y])**2 - w[r]**2
B = (sx-w[x])**2 + (sy-w[y])**2 - w[r]**2
if 0 < A and 0 < B and (tx-w[w])*(sx-w[x]) < 0:
P = abs((sy-ty)*w[x] - (sx-tx)*w[y] - (sy-ty)*tx + ty)
Q = math.sqrt((sy-ty)**2 + (sx-tx)**2)
print (float(P)/Q)
if (float(P)/Q) <= w[r]:
print 'Safe'
break
elif A*B < 0:
print 'Safe'
break
else:
print 'Danger'
while True:
N = input()
if N == 0: break
L_w = [map(int, raw_input().split()) for i in range(N)]
for i in range(input()):
tx, ty, sx, sy = map(int, raw_input().split())
f() | File "/tmp/tmp3pq2vuve/tmpvu982zvy.py", line 13
print 'Safe'
^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s623245890 | p00130 | u912237403 | 1415509550 | Python | Python | py | Runtime Error | 0 | 0 | 618 | import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def f(e1):
tx,ty,sx,sy=e1
x=[]
st=[tx-sx,ty-sy]; rst=R(st)
for e2 in WP:
wx,wy,r=e2
wt=[tx-wx,ty-wy]; rwt=R(wt)
sw=[wx-sx,wy-sy]; rsw=R(sw)
F=[rwt<r,rsw<r]
if F==[1,0] or F==[0,1]: return 0
elif F==[0,0]:
a=M.pi/2-M.acos(r/rsw)
b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
if a+1e-6>b and rst**2+1e-6>rsw**2-r**2: return 0
return 1
while 1:
n=input()
if n==0: break
WP=I(n)
P=I(input())
for e in P: print ["Safe","Danger"][f(e)] | Traceback (most recent call last):
File "/tmp/tmpsic6oxic/tmpfuy9f62h.py", line 21, in <module>
n=input()
^^^^^^^
EOFError: EOF when reading a line
| |
s764066192 | p00130 | u811733736 | 1506842308 | Python | Python3 | py | Runtime Error | 0 | 0 | 2743 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0130
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
from collections import deque
def bfs(u, result, out_edge, in_degree, processed):
# ?????????????????????????????¨??????????????¢??°
q = deque()
q.append(u)
processed[u] = True
while q:
u = q.popleft()
result.append(u)
for e in out_edge[u]:
in_degree[e] -= 1 # ?????¨?????????????????????(u)?????????????????¨???u?????\?¶????(e)????????\????¬???°???1???????????¨?????????
if in_degree[e] == 0 and processed[e] == False: # ??\????¬???°???1??????????????????0???????????°??????????????????????¬??????????????£??????????
processed[e] = True
q.append(e)
def solve(V, in_degree, out_edge):
# ????????????????????????????????????????????????
result = []
processed = [False for _ in range(V)] # ???????????????????????????????????????????????°
for i, u in enumerate(in_degree):
if u == 0 and processed[i] == False: # ??\????¬???°???0???????????????
bfs(i, result, out_edge, in_degree, processed)
return result
def decode_txt(S):
# ??\????????????????????????????§£???????????¨???????????±??¨?????´?????????????????±?????????
es = set()
cars = set() # ??????(?????????)?????°
l = len(S)
# ???????????????l -> ??? <- ?????¨???????????±?????????
for i in range(l):
if not 'a' <= S[i] <='z':
continue
s = S[i]
t = S[i+3]
num_s = ord(s) - ord('a') # ???????¨????'a'???0?????¨????????????????????°????????????
num_t = ord(t) - ord('a')
cars.add(num_s)
cars.add(num_t)
if S[i+1] == '-':
es.add(edge(num_s, num_t))
else:
es.add(edge(num_t, num_s))
if i + 3 + 1 == l:
break
return es, cars
edge = namedtuple('edge', ['f', 't'])
def main(args):
# S = 'b->a->c<-a->c->d<-c<-a<-b->a->c->d->e<-d'
n = int(input())
for _ in range(n):
S = input().strip()
es, cars = decode_txt(S)
V = len(cars)
in_degree = [0 for _ in range(V)] # ????????????????????\????¬???°
out_edge = [[] for _ in range(V)] # ???????????????????????????(??\?¶?)?????????????????????
for s, t in es:
out_edge[s].append(t)
in_degree[t] += 1
result = solve(V, in_degree, out_edge)
txt = [chr(x+ord('a')) for x in result] # ??°???????????????????????? (???: 0->'a')
print(''.join(txt))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmp_egbn1k1/tmp_o_6v0aq.py", line 84, in <module>
main(sys.argv[1:])
File "/tmp/tmp_egbn1k1/tmp_o_6v0aq.py", line 66, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s233181291 | p00130 | u811733736 | 1506842623 | Python | Python3 | py | Runtime Error | 0 | 0 | 2757 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0130
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
from collections import deque
def bfs(u, result, out_edge, in_degree, processed):
# ?????????????????????????????¨??????????????¢??°
q = deque()
q.append(u)
processed[u] = True
while q:
u = q.popleft()
result.append(u)
for e in out_edge[u]:
in_degree[e] -= 1 # ?????¨?????????????????????(u)?????????????????¨???u?????\?¶????(e)????????\????¬???°???1???????????¨?????????
if in_degree[e] == 0 and processed[e] == False: # ??\????¬???°???1??????????????????0???????????°??????????????????????¬??????????????£??????????
processed[e] = True
q.append(e)
def solve(V, in_degree, out_edge):
# ????????????????????????????????????????????????
result = []
processed = [False for _ in range(V)] # ???????????????????????????????????????????????°
for i, u in enumerate(in_degree):
if u == 0 and processed[i] == False: # ??\????¬???°???0???????????????
bfs(i, result, out_edge, in_degree, processed)
return result
def decode_txt(S):
# ??\????????????????????????????§£???????????¨???????????±??¨?????´?????????????????±?????????
es = set()
cars = set() # ??????(?????????)?????°
l = len(S)
# ???????????????l -> ??? <- ?????¨???????????±?????????
for i in range(l):
if not 'a' <= S[i] <='z':
continue
s = S[i]
t = S[i+3]
num_s = ord(s) - ord('a') # ???????¨????'a'???0?????¨????????????????????°????????????
num_t = ord(t) - ord('a')
cars.add(num_s)
cars.add(num_t)
if S[i+1] == '-':
es.add(edge(num_s, num_t))
else:
es.add(edge(num_t, num_s))
if i + 3 + 1 == l:
break
return es, cars
edge = namedtuple('edge', ['f', 't'])
def main(args):
n = int(input())
for _ in range(n):
S = input().strip()
if len(S) == 1:
print(S)
continue
es, cars = decode_txt(S)
V = len(cars)
in_degree = [0 for _ in range(V)] # ????????????????????\????¬???°
out_edge = [[] for _ in range(V)] # ???????????????????????????(??\?¶?)?????????????????????
for s, t in es:
out_edge[s].append(t)
in_degree[t] += 1
result = solve(V, in_degree, out_edge)
txt = [chr(x+ord('a')) for x in result] # ??°???????????????????????? (???: 0->'a')
print(''.join(txt))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmp4i0jokcg/tmpx2jm6x4_.py", line 87, in <module>
main(sys.argv[1:])
File "/tmp/tmp4i0jokcg/tmpx2jm6x4_.py", line 65, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s200351350 | p00130 | u811733736 | 1506842887 | Python | Python3 | py | Runtime Error | 0 | 0 | 2774 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0130
"""
import sys
from sys import stdin
input = stdin.readline
from collections import namedtuple
from collections import deque
def bfs(u, result, out_edge, in_degree, processed):
# ?????????????????????????????¨??????????????¢??°
q = deque()
q.append(u)
processed[u] = True
while q:
u = q.popleft()
result.append(u)
for e in out_edge[u]:
in_degree[e] -= 1 # ?????¨?????????????????????(u)?????????????????¨???u?????\?¶????(e)????????\????¬???°???1???????????¨?????????
if in_degree[e] == 0 and processed[e] == False: # ??\????¬???°???1??????????????????0???????????°??????????????????????¬??????????????£??????????
processed[e] = True
q.append(e)
def solve(V, in_degree, out_edge):
# ????????????????????????????????????????????????
result = []
processed = [False for _ in range(V)] # ???????????????????????????????????????????????°
for i, u in enumerate(in_degree):
if u == 0 and processed[i] == False: # ??\????¬???°???0???????????????
bfs(i, result, out_edge, in_degree, processed)
return result
def decode_txt(S):
# ??\????????????????????????????§£???????????¨???????????±??¨?????´?????????????????±?????????
es = set()
cars = set() # ??????(?????????)?????°
l = len(S)
# ???????????????l -> ??? <- ?????¨???????????±?????????
for i in range(l):
if not 'a' <= S[i] <='z':
continue
s = S[i]
try:
t = S[i+3]
except IndexError:
break
num_s = ord(s) - ord('a') # ???????¨????'a'???0?????¨????????????????????°????????????
num_t = ord(t) - ord('a')
cars.add(num_s)
cars.add(num_t)
if S[i+1] == '-':
es.add(edge(num_s, num_t))
else:
es.add(edge(num_t, num_s))
return es, cars
edge = namedtuple('edge', ['f', 't'])
def main(args):
n = int(input())
for _ in range(n):
S = input().strip()
if len(S) == 1:
print(S)
continue
es, cars = decode_txt(S)
V = len(cars)
in_degree = [0 for _ in range(V)] # ????????????????????\????¬???°
out_edge = [[] for _ in range(V)] # ???????????????????????????(??\?¶?)?????????????????????
for s, t in es:
out_edge[s].append(t)
in_degree[t] += 1
result = solve(V, in_degree, out_edge)
txt = [chr(x+ord('a')) for x in result] # ??°???????????????????????? (???: 0->'a')
print(''.join(txt))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmp_n28d17r/tmpcuklcb5x.py", line 88, in <module>
main(sys.argv[1:])
File "/tmp/tmp_n28d17r/tmpcuklcb5x.py", line 66, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s133658329 | p00130 | u203261375 | 1515366947 | Python | Python3 | py | Runtime Error | 0 | 0 | 387 | n = int(input())
for _ in range(n):
train = ''
seq = input()
for i in range(len(seq) // 3 + 1):
if i == 0:
train += seq[i]
if seq[3 * i - 2] == '-' and train[-1] == seq[3 * (i - 1)]:
train = train + seq[3 * i]
if seq[3 * i - 2] == '<' and train[0] == seq[3 * (i - 1)]:
train = seq[3 * i] + train
print(train)
| Traceback (most recent call last):
File "/tmp/tmpow__5lr2/tmp61bjbtdo.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s383046722 | p00130 | u203261375 | 1515367061 | Python | Python3 | py | Runtime Error | 0 | 0 | 387 | n = int(input())
for _ in range(n):
train = ''
seq = input()
for i in range(len(seq) // 3 + 1):
if i == 0:
train += seq[i]
if seq[3 * i - 2] == '-' and train[-1] == seq[3 * (i - 1)]:
train = train + seq[3 * i]
if seq[3 * i - 2] == '<' and train[0] == seq[3 * (i - 1)]:
train = seq[3 * i] + train
print(train)
| Traceback (most recent call last):
File "/tmp/tmp_i_k9c3b/tmpjkweol7o.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s871955494 | p00130 | u203261375 | 1515367061 | Python | Python3 | py | Runtime Error | 0 | 0 | 387 | n = int(input())
for _ in range(n):
train = ''
seq = input()
for i in range(len(seq) // 3 + 1):
if i == 0:
train += seq[i]
if seq[3 * i - 2] == '-' and train[-1] == seq[3 * (i - 1)]:
train = train + seq[3 * i]
if seq[3 * i - 2] == '<' and train[0] == seq[3 * (i - 1)]:
train = seq[3 * i] + train
print(train)
| Traceback (most recent call last):
File "/tmp/tmp5nk8qhu_/tmpnozex52d.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s728575362 | p00130 | u203261375 | 1515367524 | Python | Python3 | py | Runtime Error | 0 | 0 | 356 | n = int(input())
for _ in range(n):
train = ''
seq = input()
for i in range(0, len(seq), 3):
if i == 0:
train += seq[i]
if seq[i - 2] == '-' and train[-1] == seq[i - 3]:
train = train + seq[i]
if seq[i - 2] == '<' and train[0] == seq[i - 3]:
train = seq[i] + train
print(train)
| Traceback (most recent call last):
File "/tmp/tmpwszz0hgd/tmpz1ut8z5x.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s789241377 | p00130 | u203261375 | 1515367524 | Python | Python3 | py | Runtime Error | 0 | 0 | 356 | n = int(input())
for _ in range(n):
train = ''
seq = input()
for i in range(0, len(seq), 3):
if i == 0:
train += seq[i]
if seq[i - 2] == '-' and train[-1] == seq[i - 3]:
train = train + seq[i]
if seq[i - 2] == '<' and train[0] == seq[i - 3]:
train = seq[i] + train
print(train)
| Traceback (most recent call last):
File "/tmp/tmpee_8xub4/tmpygszvdfd.py", line 1, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s826807253 | p00132 | u912237403 | 1417961356 | Python | Python | py | Runtime Error | 0 | 0 | 2826 | import copy
def rot90(A):
#Aを時計方向に90度回転させる
return zip(*A[::-1])
def count_board(Board):
#X[x][y]: [x,y]から[Width-1,Height-1]にあるドット数のテーブルを作る
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def get_POS(n, mode, DOTS):
#n番ピースを置ける場所の洗い出し
#ピースの向き
#mode=0: 通常, mode=1: 90度回転
P0 = PIECE[(n, mode)]
P2 = PIECE[(n, mode+2)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
for j in range(Width-w+1):
tmp = DOTS[i][j] - DOTS[i+h][j] \
- DOTS[i][j+w] + DOTS[i+h][j+w]
if tmp>=s:
if tmp_put(P0, i, j): POS.append([i, j, mode])
elif tmp_put(P2, i, j): POS.append([i, j, mode+2])
return POS
def tmp_put(piece,y,x):
#ピースを枠の[x,y]に置けるかチェック
#戻り値: OK=1, NG=0
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#' and Board[y+i][x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
#mode=0: ピースを枠の[x,y]に置く
#mode=1: ピースを枠の[x,y]から取る
#戻り値: OK=1, NG=0
c = '#.'[mode]
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#': Board[y+i][x+j]=c
return Board
def solve(TRIALS, Board):
if TRIALS==[]: return 1
e = TRIALS[0]
POS = get_POS(e, 0, DOTS) + get_POS(e, 1, DOTS)
for pos in POS:
y, x, direction = pos
Board = get_put(Board, PIECE[(e, direction)], y, x, 0)
tmp = TRIALS[:]
del tmp[0]
if solve(tmp, Board): return 1
Board = get_put(Board, PIECE[(e, direction)], y, x, 1)
return 0
#パズル枠データの設定
Height, Width = map(int,raw_input().split())
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
#ピースデータの設定
PIECE = {}
n = input()
B = [0]*n
for i in range(n):
height, width = map(int,raw_input().split())
piece = [list(raw_input()) for _ in [0]*height]
B[i] = sum([e.count("#") for e in piece])
for direction in [0,1,2,3]:
PIECE[(i, direction)] = piece
piece = rot90(piece)
for _ in [0]*input():
#試すピースデータを設定し,ピースの面積と枠の面積の一致を確認
#ピースを面積の広い順にソート
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key=lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
#面積が同じならパズルを解く
print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpoo7im059/tmprkyg74pr.py", line 90
if check_sum(TRIALS): print "NO"; continue
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s774297385 | p00132 | u912237403 | 1418131170 | Python | Python | py | Runtime Error | 0 | 0 | 2417 | def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def get_POS(Board, n, mode, DOTS):
P0 = PIECE[(n, mode)]
P2 = PIECE[(n, mode+2)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
for j in range(Width-w+1):
tmp = DOTS[i][j] - DOTS[i+h][j] \
- DOTS[i][j+w] + DOTS[i+h][j+w]
if tmp>=s:
if tmp_put(Board, P0, i, j): POS.append([i, j, mode])
elif tmp_put(Board, P2, i, j): POS.append([i, j, mode+2])
return POS
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#' and Board[y+i][x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
e = TRIALS[0]
DOTS = count_board(Board)
POS = get_POS(Board, e, 0, DOTS) + get_POS(Board, e, 1, DOTS)
i=0
for pos in POS:
i=i+1
y, x, direction = pos
Board = get_put(copy.deepcopy(Board), PIECE[(e, direction)], y, x, 0)
tmp = TRIALS[:]
del tmp[0]
if solve(tmp, copy.deepcopy(Board)): return 1
Board = get_put(copy.deepcopy(Board), PIECE[(e, direction)], y, x, 1)
return 0
Height, Width = map(int,raw_input().split())
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0]*n
for i in range(n):
height, width = map(int,raw_input().split())
piece = [list(raw_input()) for _ in [0]*height]
B[i] = sum([e.count("#") for e in piece])
for direction in [0,1,2,3]:
PIECE[(i, direction)] = piece
piece = rot90(piece)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key=lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve(TRIALS, Board[:])] | File "/tmp/tmpjhly6ogr/tmpil0pfj3z.py", line 45
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s963677671 | p00132 | u912237403 | 1418134862 | Python | Python | py | Runtime Error | 19920 | 4556 | 2460 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def get_POS(Board, n, mode, DOTS):
P0 = PIECE[(n, mode)]
P2 = PIECE[(n, mode+2)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
for j in range(Width-w+1):
tmp = DOTS[i][j] - DOTS[i+h][j] \
- DOTS[i][j+w] + DOTS[i+h][j+w]
if tmp>=s:
if tmp_put(Board, P0, i, j): POS.append([i, j, mode])
elif tmp_put(Board, P2, i, j): POS.append([i, j, mode+2])
return POS
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#' and Board[y+i][x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
e = TRIALS[0]
DOTS = count_board(Board)
POS = get_POS(Board, e, 0, DOTS) + get_POS(Board, e, 1, DOTS)
i=0
for pos in POS:
i=i+1
y, x, direction = pos
Board = get_put(Board, PIECE[(e, direction)], y, x, 0)
tmp = TRIALS[:]
del tmp[0]
if solve(tmp, Board): return 1
Board = get_put(Board, PIECE[(e, direction)], y, x, 1)
return 0
while 1:
Height, Width = map(int,raw_input().split())
if Height==Width==0: break
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0]*n
for i in range(n):
height, width = map(int,raw_input().split())
piece = [list(raw_input()) for _ in [0]*height]
B[i] = sum([e.count("#") for e in piece])
for direction in [0,1,2,3]:
PIECE[(i, direction)] = piece
piece = rot90(piece)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key=lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmppaxkg2mn/tmp38jyponx.py", line 46
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s186845521 | p00132 | u912237403 | 1418136703 | Python | Python | py | Runtime Error | 19930 | 4572 | 2418 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def get_POS(Board, n, mode, DOTS):
P0 = PIECE[(n, mode)]
P2 = PIECE[(n, mode+2)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
for j in range(Width-w+1):
tmp = DOTS[i][j] - DOTS[i+h][j] \
- DOTS[i][j+w] + DOTS[i+h][j+w]
if tmp>=s:
if tmp_put(Board, P0, i, j): POS.append([i, j, mode])
elif tmp_put(Board, P2, i, j): POS.append([i, j, mode+2])
return POS
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#' and Board[y+i][x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
for j in range(len(piece[0])):
if piece[i][j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
e = TRIALS[0]
DOTS = count_board(Board)
POS = get_POS(Board, e, 0, DOTS) + get_POS(Board, e, 1, DOTS)
i=0
for pos in POS:
i=i+1
y, x, direction = pos
Board1 = get_put(copy.deepcopy(Board), PIECE[(e, direction)], y, x, 0)
tmp = TRIALS[:]
del tmp[0]
if solve(tmp, Board1): return 1
return 0
while 1:
Height, Width = map(int,raw_input().split())
if Height==Width==0: break
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0]*n
for i in range(n):
height, width = map(int,raw_input().split())
piece = [list(raw_input()) for _ in [0]*height]
B[i] = sum([e.count("#") for e in piece])
for direction in [0,1,2,3]:
PIECE[(i, direction)] = piece
piece = rot90(piece)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key=lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpy569r_ii/tmpgzy8_k1r.py", line 46
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s349947337 | p00132 | u912237403 | 1418241252 | Python | Python | py | Runtime Error | 19930 | 4592 | 2607 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in range(len(piece[0])):
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
tmp = piece[i]
for j in range(len(piece[0])):
if tmp[j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve1(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P0 = PIECE[(n, direction)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in range(Width-w+1):
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P0, i, j):
Board = get_put(Board, P0, i, j, 0)
tmp = TRIALS[:]
del tmp[0]
if solve1(tmp, Board): return 1
Board = get_put(Board, P0, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i,x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1],[1,3],[0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height==Width==0: break
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0]*n
C = [[0 for _ in [0]*4] for _ in [0]*n]
for i in range(n):
height, width = map(int,raw_input().split())
piece = [list(raw_input()) for _ in [0]*height]
B[i] = sum([e.count('#') for e in piece])
for direction in [0,1,2,3]:
PIECE[(i, direction)] = piece
piece = rot90(piece)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key=lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve1(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpmt68pnld/tmp7jtf_bzu.py", line 33
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s108787445 | p00132 | u912237403 | 1418405894 | Python | Python | py | Runtime Error | 0 | 0 | 2668 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in range(len(piece[0])):
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
tmp = piece[i]
for j in range(len(piece[0])):
if tmp[j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve1(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P0 = PIECE[(n, direction)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in range(Width-w+1):
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P0, i, j):
Board = get_put(Board, P0, i, j, 0)
tmp = TRIALS[:]
del tmp[0]
if solve1(tmp, Board): return 1
Board = get_put(Board, P0, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
start_time = time.clock()
while 1:
try:
Height, Width = map(int,raw_input().split())
except:
break
if Height==Width==0: break
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0 for _ in [0]*4] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve1(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpr509rxyu/tmpbwvbn6c4.py", line 33
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s491547415 | p00132 | u912237403 | 1418405988 | Python | Python | py | Runtime Error | 19930 | 4580 | 2640 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in range(len(piece[0])):
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
for i in range(len(piece)):
tmp = piece[i]
for j in range(len(piece[0])):
if tmp[j]=='#': Board[y+i][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve1(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P0 = PIECE[(n, direction)]
h = len(P0)
w = len(P0[0])
s = B[n]
POS=[]
for i in range(Height-h+1):
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in range(Width-w+1):
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P0, i, j):
Board = get_put(Board, P0, i, j, 0)
tmp = TRIALS[:]
del tmp[0]
if solve1(tmp, Board): return 1
Board = get_put(Board, P0, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
try:
Height, Width = map(int,raw_input().split())
except:
break
if Height==Width==0: break
Board = [list(raw_input()) for i in range(Height)]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0 for _ in [0]*4] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:[-x[0]])
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"; continue
print ["NO", "YES"][solve1(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpctkxlk4w/tmpsgd0ik8x.py", line 33
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s539458559 | p00132 | u912237403 | 1421046300 | Python | Python | py | Runtime Error | 0 | 0 | 3163 | import copy
def rot90(A):
#Aを時計方向に90度回転させる
return zip(*A[::-1])
def count_board(Board):
#Board [0,0]から[Width-1,Height-1]にあるドット数のテーブルを作る
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
#ピースを枠の[x,y]に置けるかチェック
#戻り値: OK=1, NG=0
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
#mode=0: ピースを枠の[x,y]に置く
#mode=1: ピースを枠の[x,y]から取る
#戻り値: OK=1, NG=0
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
#パズル枠データの設定
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
#ピースデータの設定
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
#試すピースデータを設定し,ピースの面積と枠の面積の一致を確認
#ピースを面積の広い順にソート
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
#面積が同じならパズルを解く
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpp253lgdo/tmppstdap46.py", line 43
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s448476333 | p00132 | u912237403 | 1421046420 | Python | Python | py | Runtime Error | 19930 | 4632 | 2587 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmppwg6zto8/tmpwdi28c4c.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s787816736 | p00132 | u912237403 | 1421053289 | Python | Python | py | Runtime Error | 19930 | 4632 | 2584 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpaaqf7er1/tmpr415cbu0.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s023956144 | p00132 | u912237403 | 1421053521 | Python | Python | py | Runtime Error | 19930 | 4596 | 2605 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
try: Board = [list(raw_input()) for _ in [0]*Height]
except: break
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpbzht03u4/tmpz38jg340.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s954025855 | p00132 | u912237403 | 1421054213 | Python | Python | py | Runtime Error | 19930 | 4596 | 2613 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
try:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
except: break
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp_ilxdxea/tmprvjs0gtv.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s505386006 | p00132 | u912237403 | 1421054275 | Python | Python | py | Runtime Error | 19930 | 4596 | 2619 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
try:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
except: break
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp8jkudoop/tmpx_4_bkeh.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s815384666 | p00132 | u912237403 | 1421054351 | Python | Python | py | Runtime Error | 19930 | 4596 | 2639 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
try:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
except: break
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp6ciko8nw/tmpbyj7zhfj.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s885015040 | p00132 | u912237403 | 1421054435 | Python | Python | py | Runtime Error | 19930 | 4596 | 2651 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
try:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))]
except: break | File "/tmp/tmp1mwc79mt/tmprq64u3jh.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s535800765 | p00132 | u912237403 | 1421054643 | Python | Python | py | Runtime Error | 19930 | 4632 | 2645 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
try:
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
tmp = list(set(flg))
except: tmp = [0,1,2,3]
return tmp
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp8czfkavy/tmpyjvaztm4.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s982113143 | p00132 | u912237403 | 1421054741 | Python | Python | py | Runtime Error | 19930 | 4592 | 2652 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
try:
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
except: return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp_finjli3/tmpowlj91es.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s274214663 | p00132 | u912237403 | 1421054914 | Python | Python | py | Runtime Error | 19930 | 4636 | 2630 | import copy
def rot90(A):
try:
tmp = zip(*A[::-1])
return tmp
except:
return A
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpuooxzavm/tmp4titvcdk.py", line 40
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s345337409 | p00132 | u912237403 | 1421055084 | Python | Python | py | Runtime Error | 19930 | 4596 | 2668 | import copy
def rot90(A):
try:
tmp = zip(*A[::-1])
return tmp
except:
return A
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
try:
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
except:
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpp_d2l2zw/tmple00_w6o.py", line 43
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s678080860 | p00132 | u912237403 | 1421055210 | Python | Python | py | Runtime Error | 19930 | 4636 | 2708 | import copy
def rot90(A):
try:
tmp = zip(*A[::-1])
return tmp
except:
return A
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
try:
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
except:
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
try:
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
except: return 0
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpaz7wr5g3/tmpmdgbe7wz.py", line 45
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s411732044 | p00132 | u912237403 | 1421055471 | Python | Python | py | Runtime Error | 19930 | 4620 | 2482 | import copy
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
try:
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
except: return Board
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmp82um5xjt/tmpxtkiais9.py", line 90
if check_sum(TRIALS): print "NO"
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s694074740 | p00132 | u912237403 | 1421504949 | Python | Python | py | Runtime Error | 0 | 0 | 3214 | import copy,sys
def rot90(A):
#Aを時計方向に90度回転させる
return zip(*A[::-1])
def count_board(Board):
#Board [0,0]から[Width-1,Height-1]にあるドット数のテーブルを作る
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
#ピースを枠の[x,y]に置けるかチェック
#戻り値: OK=1, NG=0
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
#mode=0: ピースを枠の[x,y]に置く
#mode=1: ピースを枠の[x,y]から取る
#戻り値: OK=1, NG=0
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
start_time = time.clock()
sys.setrecursionlimit(15)
#パズル枠データの設定
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
#ピースデータの設定
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
#試すピースデータを設定し,ピースの面積と枠の面積の一致を確認
#ピースを面積の広い順にソート
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
#面積が同じならパズルを解く
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpxrvx39wl/tmpx57b6cvs.py", line 43
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s823539432 | p00132 | u912237403 | 1421505065 | Python | Python | py | Runtime Error | 0 | 0 | 2644 | import copy,sys
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
start_time = time.clock()
sys.setrecursionlimit(15)
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpgiipv4oh/tmpbco_7cp9.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s367597703 | p00132 | u912237403 | 1421505091 | Python | Python | py | Runtime Error | 19930 | 4604 | 2617 | import copy,sys
def rot90(A):
return zip(*A[::-1])
def count_board(Board):
X = [[0 for _ in [0]*(Width+1)] for _ in [0]*(Height+1)]
for i in range(Height)[::-1]:
for j in range(Width)[::-1]:
X[i][j] = X[i+1][j] + X[i][j+1] - X[i+1][j+1] + (Board[i][j]=='.')
return X
def check_sum(TRIALS):
return sum([B[e] for e in TRIALS]) != DOTS[0][0]
def tmp_put(Board, piece, y, x):
N = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
BoardRow = Board[y+i]
for j in N:
if tmp[j]=='#' and BoardRow[x+j]!='.': return 0
return 1
def get_put(Board, piece, y, x, mode):
c = '#.'[mode]
W = range(len(piece[0]))
for i in range(len(piece)):
tmp = piece[i]
Y = y+i
for j in W:
if tmp[j]=='#': Board[Y][x+j]=c
return Board
def PrintBoard(Board):
for e in Board:
print "".join(e)
print
return
def PrintDots(DOTS):
for e in DOTS:
print e
print
return
def solve(TRIALS, Board):
if TRIALS==[]: return 1
n = TRIALS[0]
DOTS = count_board(Board)
for direction in C[n]:
P = PIECE[(n, direction)]
h = len(P)
w = len(P[0])
s = B[n]
POS=[]
H = range(Height-h+1)
W = range(Width-w+1)
for i in H:
A1 = DOTS[i]
A2 = DOTS[i+h]
for j in W:
tmp = A1[j] - A2[j] - A1[j+w] + A2[j+w]
if tmp>=s and tmp_put(Board, P, i, j):
Board = get_put(Board, P, i, j, 0)
if solve(TRIALS[1:], Board): return 1
Board = get_put(Board, P, i, j, 1)
return 0
def CheckPieceType(i):
def f(x1, x2):
for j in range(len(PIECE[i, x1])):
if "".join(PIECE[i, x1][j])!="".join(PIECE[i, x2][j]): return 0
return 1
flg = [0,1,2,3]
for a, b in [[0,1], [1,3], [0,2]]:
if f(a, b): flg[b] = flg[a]
return list(set(flg))
sys.setrecursionlimit(15)
while 1:
Height, Width = map(int,raw_input().split())
if Height*Width==0: break
Board = [list(raw_input()) for _ in [0]*Height]
DOTS = count_board(Board)
PIECE = {}
n = input()
B = [0] * n
C = [[0, 0, 0, 0] for _ in [0] * n]
for i in range(n):
height, width = map(int, raw_input().split())
tmp = [list(raw_input()) for _ in [0] * height]
B[i] = sum([e.count('#') for e in tmp])
for direction in [0, 1, 2, 3]:
PIECE[(i, direction)] = tmp
tmp = rot90(tmp)
C[i] = CheckPieceType(i)
for _ in [0]*input():
a = map(int, raw_input().split())[1:]
a = sorted([[B[e-1], e-1] for e in a], key = lambda x:{-x[0]})
TRIALS = list(zip(*a)[1])
if check_sum(TRIALS): print "NO"
else: print ["NO", "YES"][solve(TRIALS, copy.deepcopy(Board))] | File "/tmp/tmpqhds7wlp/tmpnqahqed4.py", line 36
print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s952825202 | p00135 | u041086527 | 1416384842 | Python | Python | py | Runtime Error | 0 | 0 | 361 |
n = input()
for i in range(n):
h,m = map(int, raw_input().split(":"))
sangle = 1.0 * 360 * (h * 60 + m) / 720
langle = 1.0 * 360 * m / 60
angle = abs(sangle - langle)
if angle > 180:
angle = 360 - d
if (0 <= angle < 30):
print "alert"
elif (90 <= angle <= 180):
print "safe"
else:
print "warning" | File "/tmp/tmpt01x3e_w/tmpzab_zh3r.py", line 11
print "alert"
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s883430966 | p00135 | u873482706 | 1435983770 | Python | Python | py | Runtime Error | 0 | 0 | 63 | N = input()
print sum([int(raw_input()) for i in range(N)]) / N | File "/tmp/tmptwtactxc/tmpqqi64qv2.py", line 2
print sum([int(raw_input()) for i in range(N)]) / N
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s816584812 | p00135 | u301729341 | 1482905915 | Python | Python | py | Runtime Error | 0 | 0 | 321 | import math
n = int(input())
for i in range(n):
m,s = map(int,input().split(":"))
m_kak = 30 * m + 0.5 * s
s_kak = 6 * s
kak = min(math.fabs(m_kak - s_kak), 360 - math.fabs(m_kak - s_kak) )
if kak < 30:
print("alert")
elif kak < 90:
print("warning")
else:
print("safe") | Traceback (most recent call last):
File "/tmp/tmp64mroxvm/tmpmr4mre46.py", line 2, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s678765699 | p00135 | u811733736 | 1505443439 | Python | Python3 | py | Runtime Error | 0 | 0 | 976 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0135
WA
"""
import sys
from sys import stdin
from math import sqrt, acos, cos, sin, radians, degrees
input = stdin.readline
def solve(time):
# 12????????????90???
short_hand_angle = time[1] * -6 + 90
x_s = cos(radians(short_hand_angle))
y_s = sin(radians(short_hand_angle))
long_hand_angle = (time[0]*60+time[1])/(12*60) * -360 + 90
x_l = cos(radians(long_hand_angle))
y_l = sin(radians(long_hand_angle))
c = (x_s * x_l + y_s * y_l) / (sqrt(x_s**2 + y_s**2) * sqrt(x_l**2 + y_l**2))
ans = degrees(acos(c))
if ans < 30:
return 'alert'
elif ans >= 90:
return 'safe'
else:
return 'warning'
def main(args):
# n = int(input())
n = 1
for _ in range(n):
time = [int(x) for x in input().split(':')]
result = solve(time)
print(result)
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmpjokpebk1/tmpu9hqy5nz.py", line 42, in <module>
main(sys.argv[1:])
File "/tmp/tmpjokpebk1/tmpu9hqy5nz.py", line 36, in main
time = [int(x) for x in input().split(':')]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpjokpebk1/tmpu9hqy5nz.py", line 36, in <listcomp>
time = [int(x) for x in input().split(':')]
^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s509505589 | p00135 | u104911888 | 1367129177 | Python | Python | py | Runtime Error | 0 | 0 | 265 | n=input()
for i in range(n):
hh,mm=map(int,raw_input().split(":"))
angleh=(60*hh+mm)*0.5
anglem=6*mm
diff=math.abs(angleh-anglem)
if 0<=diff<30:
print "alert"
elif 90<=diff<=180:
print "safe"
else:
print "warning" | File "/tmp/tmpdbieydwl/tmpnq4c7w1a.py", line 8
print "alert"
^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s587910292 | p00136 | u314932236 | 1513701596 | Python | Python | py | Runtime Error | 0 | 0 | 563 | import os
import math
def main():
lst = [0,0,0,0,0,0]
for i in range(0, int(input())):
temp = float(input())
if temp < 165:
lst[0] += 1
elif temp < 170:
lst[1] += 1
elif temp < 175:
lst[2] += 1
elif temp < 180:
lst[3] += 1
elif temp < 185:
lst[4] += 1
else:
lst[5] += 1
for i in range(0,6):
print("{}:".format(i+1), end="")
for j in range(0,lst[i]):
print("*", end = "")
print()
main() | Traceback (most recent call last):
File "/tmp/tmpvwd7jd9p/tmp0ievqa9k.py", line 26, in <module>
main()
File "/tmp/tmpvwd7jd9p/tmp0ievqa9k.py", line 6, in main
for i in range(0, int(input())):
^^^^^^^
EOFError: EOF when reading a line
| |
s743498219 | p00136 | u633068244 | 1394901883 | Python | Python | py | Runtime Error | 0 | 0 | 396 | histo = ["" for i in range(6)]
n = int(raw_input())
for i in range(n):
h = float(raw_input())
if h < 165.0:
histo[0] += "*"
elif h < 170.0:
histo[1] += "*"
elif h < 175.0:
histo[2] += "*"
elif h < 180.0:
histo[3] += "*"
elif h < 185.0:
histo[4] += "*"
else:
histo[5] += "*"
for i in range(6):
print "%d:%a"%(i,a[i]) | File "/tmp/tmpillwz0c1/tmputz3hoo4.py", line 19
print "%d:%a"%(i,a[i])
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s976808194 | p00137 | u855694108 | 1504740088 | Python | Python3 | py | Runtime Error | 0 | 0 | 605 | import sys
def main():
for line in sys.stdin:
n = int(line)
for x in range(1, n + 1):
s = int(input())
a = [] #answer
for _ in range(10):
s = "{0:08d}".format(s ** 2)
s = list(s)
hoge = ""
for y in range(2, 6):
hoge += s[y]
s = int(hoge)
a.append(s)
else:
print("Case", x,end = "")
print(":")
for y in a:
print(y)
if __name__ == "__main__":
main() | ||
s067992335 | p00137 | u855694108 | 1504740219 | Python | Python3 | py | Runtime Error | 0 | 0 | 503 |
def main():
n = int(iuput())
for x in range(1, n + 1):
s = int(input())
a = [] #answer
for _ in range(10):
s = "{0:08d}".format(s ** 2)
s = list(s)
hoge = ""
for y in range(2, 6):
hoge += s[y]
s = int(hoge)
a.append(s)
else:
print("Case", x,end = "")
print(":")
for y in a:
print(y)
if __name__ == "__main__":
main() | Traceback (most recent call last):
File "/tmp/tmpp76ny9oa/tmpimo1wnyy.py", line 23, in <module>
main()
File "/tmp/tmpp76ny9oa/tmpimo1wnyy.py", line 3, in main
n = int(iuput())
^^^^^
NameError: name 'iuput' is not defined. Did you mean: 'input'?
| |
s538006169 | p00137 | u633068244 | 1394960931 | Python | Python | py | Runtime Error | 0 | 0 | 164 | n = int(raw_input())
for i in range(n):
s = int(raw_input())
print "Case %d:"%(i+1)
for j in range(10):
s =int(str(s**2)[-6:-2])
print s | File "/tmp/tmprztx3jbd/tmp093nq9rd.py", line 4
print "Case %d:"%(i+1)
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s441111304 | p00138 | u879226672 | 1427691082 | Python | Python | py | Runtime Error | 0 | 0 | 572 | ls = []
for i in range(2):
n,t = raw_input().split()
ls.append([n,float(t)])
ls1 = sorted(ls[:9], key=lambda x:x[1])
ls2 = sorted(ls[9:17], key=lambda x:x[1])
ls3 = sorted(ls[17:], key=lambda x:x[1])
print ' '.join(map(str,ls1[0]))
print ' '.join(map(str,ls1[1]))
print ' '.join(map(str,ls2[0]))
print ' '.join(map(str,ls2[1]))
print ' '.join(map(str,ls3[0]))
print ' '.join(map(str,ls3[1]))
del ls1[0],ls1[1],ls2[0],ls2[1],ls3[0],ls3[1]
ls_merg = sorted(ls1 + ls2 + ls3, key=lambda x:x[1])
print ' '.join(map(str,ls_merg[0]))
print ' '.join(map(str,ls_merg[1]))
| File "/tmp/tmpaecqajnt/tmpr2vsiosq.py", line 8
print ' '.join(map(str,ls1[0]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s832415639 | p00138 | u859393176 | 1448538690 | Python | Python | py | Runtime Error | 0 | 0 | 370 | l = [[], [], []]
ans = []
for i in range(3):
for j in range(8):
s = raw_input().split()
l[i].append(float(s[1]), int(s[0]))
for i in range(3):
l[i].sort()
l[i].reverse()
ans.append(l[i].pop(0))
ans.append(l[i].pop(0))
l = l[0] + l[1] + [2]
l.sort()
l.reverse()
ans.append(l.pop(0))
ans.append(l.pop(0))
for n in ans:
print str(n[1]) + " " + str(n[0]) | File "/tmp/tmp7lurl4v4/tmphzdi6fka.py", line 18
print str(n[1]) + " " + str(n[0])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s982495113 | p00138 | u546285759 | 1507866016 | Python | Python3 | py | Runtime Error | 0 | 0 | 267 | dataset = [[input().split() for _ in range(8)] for _ in range(3)]
tmp = []
for i in range(3):
s = sorted(dataset[i], key=lambda x: x[1])[:3]
tmp.append(s[-1])
for p in s[:2]:
print(*p)
a, b = sorted(tmp, key=lambda x: x[1])[:2]
print(*a, "\n", *b) | Traceback (most recent call last):
File "/tmp/tmpo6_ecaym/tmpj49q1vbv.py", line 1, in <module>
dataset = [[input().split() for _ in range(8)] for _ in range(3)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpo6_ecaym/tmpj49q1vbv.py", line 1, in <listcomp>
dataset = [[input().split() for _ in range(8)] for _ in range(3)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpo6_ecaym/tmpj49q1vbv.py", line 1, in <listcomp>
dataset = [[input().split() for _ in range(8)] for _ in range(3)]
^^^^^^^
EOFError: EOF when reading a line
| |
s049377538 | p00138 | u808429775 | 1519096515 | Python | Python | py | Runtime Error | 0 | 0 | 599 | import heapq
from collections import namedtuple
Data = namedtuple("Data", ("time", "number"))
all_player = []
for _ in range(3):
player = [input().split(" ") for lp in range(8)]
player = [Data(float(time), number) for number, time in player]
heapq.heapify(player)
data = heapq.heappop(player)
print(data.number, data.time)
data = heapq.heappop(player)
print(data.number, data.time)
all_player.extend(player)
heapq.heapify(all_player)
data = heapq.heappop(all_player)
print(data.number, data.time)
data = heapq.heappop(all_player)
print(data.number, data.time)
| Traceback (most recent call last):
File "/tmp/tmpkqmzs12v/tmpn4iwkx48.py", line 9, in <module>
player = [input().split(" ") for lp in range(8)]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/tmpkqmzs12v/tmpn4iwkx48.py", line 9, in <listcomp>
player = [input().split(" ") for lp in range(8)]
^^^^^^^
EOFError: EOF when reading a line
| |
s895146965 | p00139 | u489809100 | 1449070289 | Python | Python | py | Runtime Error | 0 | 0 | 438 | def snakeJudge(snake):
if snake[:2] == ">'" :
snake = snake[2 : len(snake) - 1]
x1 = snake[0 : snake.index("#")]
x2 = snake[snake.index("#") + 1: len(snake)]
if x1 == x2 : return "A"
if snake[:2] == ">^" :
judge = True
snake = snake[2 : len(snake) - 2]
x1 = snake.count("Q=")
x2 = len(snake)
if x2 / 2 == x1 : return "B"
return "NA"
n = input()
for i in range(0, n):
snake = raw_input()
print snakeJudge(snake) | File "/tmp/tmpdg76cvk2/tmp5fzlbdr2.py", line 19
print snakeJudge(snake)
^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s754242452 | p00139 | u078042885 | 1486778636 | Python | Python3 | py | Runtime Error | 0 | 0 | 241 | for _ in [0]*int(input()):
s=input()
if s[1]=='\'':
a=s[2:-1].split('#')
print(['NA','A'][set(a[0])==set(a[1])=={'='} and len(set(a))==1])
else:
s=s[2:-2]
print(['NA','B'][len(s)==2*s.count('Q=')]) | Traceback (most recent call last):
File "/tmp/tmp47k508km/tmp0mmyg8e4.py", line 1, in <module>
for _ in [0]*int(input()):
^^^^^^^
EOFError: EOF when reading a line
| |
s493043244 | p00139 | u078042885 | 1486778816 | Python | Python3 | py | Runtime Error | 0 | 0 | 287 | for _ in [0]*int(input()):
s=input()
if s[:2]=='>\'' and s[-1]=='~':
a=s[2:-1].split('#')
print(['NA','A'][set(a[0])==set(a[1])=={'='} and len(set(a))==1])
elif s[:2]=='>^' and s[-2:]=='~~':
s=s[2:-2]
print(['NA','B'][len(s)==2*s.count('Q=')]) | Traceback (most recent call last):
File "/tmp/tmpkhp2dpe0/tmp12ituc3a.py", line 1, in <module>
for _ in [0]*int(input()):
^^^^^^^
EOFError: EOF when reading a line
| |
s630722231 | p00140 | u633068244 | 1397213959 | Python | Python | py | Runtime Error | 0 | 0 | 211 | stop=[0,1,2,3,4,5,6,7,8,9,5,4,3,2,1,0]
for i in range(input()):
sp,ep=map(int,raw_input().split())
if sp<ep:
print stop[stop.index(sp):stop.index(ep)+1]
else:
print stop[stop.rindex(sp):stop.rindex(ep)+1] | File "/tmp/tmpbugbwwvp/tmpxoj2wj20.py", line 5
print stop[stop.index(sp):stop.index(ep)+1]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s794703891 | p00140 | u260980560 | 1400217888 | Python | Python | py | Runtime Error | 0 | 0 | 354 | bus = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1, 0]
for i in xrange(input()):
s, t = map(int, raw_input().split())
if s>5:
print " ".join(map(str, bus[s:bus.index(t, s)+1]))
else:
if s<t:
print " ".join(map(str, range(s, t+1)))
else:
print " ".join(map(str, xrange(s, t-1, -1)))
| File "/tmp/tmpsakezpcg/tmp9wrbvnj8.py", line 5
print " ".join(map(str, bus[s:bus.index(t, s)+1]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s572510749 | p00141 | u912237403 | 1418438665 | Python | Python | py | Runtime Error | 0 | 0 | 387 | for _ in [0]*input():
n = input()
A = [list(' '*n) for _ in [0]*n]
for i in range((n+3)/4):
i2 = i*2
if i2>0: A[n-i2][i2]='@'
for j in range(i2, n-i2):
A[j][i2]='@' #左下→左上
A[i2][j]='@' #左上→右上
if j<n-i2-1: A[j][n-i2-1]='@' #右上→右下
if j>i2+1: A[n-i2-1][j]='@' #右下→左下下
for e in A: print "".join(e)
print | File "/tmp/tmpixbtwcc4/tmpk8nyqy3p.py", line 12
for e in A: print "".join(e)
^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s176500224 | p00141 | u811733736 | 1507215814 | Python | Python3 | py | Runtime Error | 0 | 0 | 1093 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0141
"""
import sys
from sys import stdin
input = stdin.readline
from itertools import cycle
def guruguru(n):
if n < 5:
return
line = 0
dirs = cycle([(0, -1), (1, 0), (0, 1), (-1, 0)])
M = [[' '] * n for _ in range(n)]
cx = 0
cy = n - 1
while line < n:
line += 1
dx, dy = dirs.__next__()
while True:
M[cy][cx] = '#'
nx = cx + dx
ny = cy + dy
nnx = nx + dx
nny = ny + dy
if nx < 0 or nx >= n:
break
if ny < 0 or ny >= n:
break
if nny < 0 or nny >= n or nnx < 0 or nnx >= n:
pass
else:
if M[nny][nnx] != ' ':
break
cx = nx
cy = ny
for l in M:
print(''.join(map(str, l)))
def main(args):
for line in sys.stdin:
n = int(line)
guruguru(n)
if __name__ == '__main__':
main(sys.argv[1:])
| ||
s477370985 | p00141 | u633068244 | 1399230567 | Python | Python | py | Runtime Error | 0 | 0 | 410 | for r in range(input()):
if r > 0: print
n = input()
S = [[" "]*n for i in range(n)]
x,y,dx,dy = 0,n-1,0,-1
while 1:
S[y][x] = "#"
y += dy; x += dx
try:
if y+dy == -1: raise
if S[y+dy][x+dx] == "#":
y -= dy; x -= dx
raise
except:
S[y][x] = "#"
dx,dy = -dy,dx
y += dy; x += dx
if S[y+dy][x+dx] == "#" or S[y+dx][x-dy] == "#": break
for i in range(n):
print "".join(S[i]) | File "/tmp/tmpd305hea7/tmpgtmgtz8t.py", line 20
print "".join(S[i])
^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s668518452 | p00142 | u633068244 | 1418396520 | Python | Python | py | Runtime Error | 0 | 0 | 1204 | #include <iostream>
#include <set>
using namespace std;
const int MAX = 5001;
int main(void){
int square[MAX];
for (int i=1; i < MAX+1; i++) square[i-1] = i*i;
while (true){
int n;
cin >> n;
if (n == 0) break;
int m = (n-1)/2;
int raw_mod[n-1],mod[m];
for(int i = 0; i < n-1; i++) raw_mod[i] = square[i]%n;
sort(raw_mod,raw_mod+n-1);
mod[0] = raw_mod[0];
int size;
for(int i = 1, j = 1; i < n-1; i++){
if (mod[j-1] != raw_mod[i]){
mod[j] = raw_mod[i];
j++;
}
size = j;
}
int hist[MAX] = {};
for (int i = 0; i < size-1; i++)
for (int j = i+1; j < size; j++){
int tmp1 = mod[i]-mod[j];
if (tmp1 < 0) tmp1 += n;
if (tmp1 > m) tmp1 = n-tmp1;
int tmp2 = mod[j]-mod[i];
if (tmp2 < 0) tmp2 += n;
if (tmp2 > m) tmp2 = n-tmp2;
hist[tmp1-1] += 1;
hist[tmp2-1] += 1;
}
for(int i = 0; i < m; i++)
cout << hist[i] << endl;
}
return 0;
} | File "/tmp/tmpe23qcqx0/tmp7s_n0rs6.py", line 3
using namespace std;
^^^^^^^^^
SyntaxError: invalid syntax
| |
s854448445 | p00142 | u759934006 | 1426334235 | Python | Python3 | py | Runtime Error | 0 | 0 | 411 | # 0142 - Nature of Prime Numbers
while True:
n = int(input())
if n == 0: break
_min = 0
_max = int((n - 1) / 2)
print(_min, _max)
ns = set([ x * x % n for x in range(1, n)])
count = {}
for i in ns:
for j in ns:
if i < j:
m = i - j
if m < _min: m = n + m
if m > _max: m = n - m
count.setdefault(m, 0)
count[m] += 1
for i in range(1, int((n - 1) / 2 + 1)):
print(count[i] * 2) | File "/tmp/tmpb7seoxik/tmpxofgh3ha.py", line 17
m = i - j
TabError: inconsistent use of tabs and spaces in indentation
| |
s571561593 | p00142 | u759934006 | 1426334263 | Python | Python3 | py | Runtime Error | 0 | 0 | 416 | # 0142 - Nature of Prime Numbers
while True:
n = int(input())
if n == 0: break
_min = 0
_max = int((n - 1) / 2)
print(_min, _max)
ns = set([ x * x % n for x in range(1, n)])
count = {}
for i in ns:
for j in ns:
if i < j:
m = i - j
if m < _min: m = n + m
if m > _max: m = n - m
count.setdefault(m, 0)
count[m] += 1
for i in range(1, int((n - 1) / 2 + 1)):
print(count[i] * 2) | File "/tmp/tmpevr54mkx/tmp2fvw9won.py", line 17
m = i - j
TabError: inconsistent use of tabs and spaces in indentation
| |
s548895124 | p00142 | u847467233 | 1529618005 | Python | Python3 | py | Runtime Error | 0 | 0 | 809 | # AOJ 0142 Nature of Prime Numbers
# Python3 2018.6.22 bal4u
MAX = 10000
HALF = 5003
not_prime = [0]*MAX
tbl = [3, 5, 7, 11, 13, 17, 19, 23, 29, 31, \
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
def sieve():
for i in tbl:
for j in range(i*i, MAX, i): not_prime[j] = 1
sieve()
while 1:
n = int(input())
if n == 0: break
k = n >> 1
# 4m+3の素数
if not_prime[n] == 0 and (n & 3) == 3:
print(*[k-1]*k, sep='\n')
continue;
# 他の奇数についてはまじめに計算
d = [0]*HALF
f = [0]*HALF
a = []
m = 0;
for i in range(1, k+1):
b = i*i % n;
if f[b] == 0:
f[b] = 1
a.append(b)
for i in range(len(a)):
for j in range(i):
b = a[i]-a[j]
if b == 0: continue
if b < 0: b += n
if b > k: b = n-b
d[b] += 1
for i in range(1, k+1): print(d[i]<<1)
| Traceback (most recent call last):
File "/tmp/tmpqkwxq8k_/tmp005nvvku.py", line 16, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s238837369 | p00142 | u633068244 | 1398334314 | Python | Python | py | Runtime Error | 0 | 0 | 295 | while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i in range(l):
for j in range(i+1,l):
d = a[i] - a[j]
if d <= m - n:
d += n
elif d < 0:
d *= -1
h[d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmp4wl2su32/tmp7k1whwwk.py", line 17
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s801310300 | p00142 | u633068244 | 1398334339 | Python | Python | py | Runtime Error | 0 | 0 | 295 | while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i in range(l):
for j in range(i+1,l):
d = a[i] - a[j]
if d <= m - n:
d += n
elif d < 0:
d *= -1
h[d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmpyl4ior4s/tmpjgwcifua.py", line 17
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s602589394 | p00142 | u633068244 | 1398334442 | Python | Python | py | Runtime Error | 0 | 0 | 295 | while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i in range(l):
for j in range(i+1,l):
d = a[i] - a[j]
if d <= m - n:
d += n
elif d < 0:
d *= -1
h[d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmpix1z377l/tmp5d44f3pq.py", line 17
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s511121569 | p00142 | u633068244 | 1398334456 | Python | Python | py | Runtime Error | 0 | 0 | 292 | while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i in range(l):
for j in range(i+1,l):
d = a[i] - a[j]
if d < m - n:
d += n
elif d < 0:
d = -d
h[d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmpyx4lx97w/tmppnrjhj00.py", line 17
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s885442872 | p00142 | u633068244 | 1398334558 | Python | Python | py | Runtime Error | 0 | 0 | 294 | while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i in range(l):
for j in range(i+1,l):
d = a[i] - a[j]
if d <= m - n:
d += n
elif d < 0:
d *= -1
h[d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmpikwz0gxg/tmp6wzw64mn.py", line 17
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s786519198 | p00142 | u633068244 | 1398335108 | Python | Python | py | Runtime Error | 0 | 0 | 292 | import itertools
while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i,j in itertools.combinations(a,2):
d = i - j
if d < 0:
d += n
h[d] += 2 if d <= m else h[n-d] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmpzkza0yyr/tmp5b725n37.py", line 13
h[d] += 2 if d <= m else h[n-d] += 2
^^
SyntaxError: invalid syntax
| |
s819306964 | p00142 | u633068244 | 1398335257 | Python | Python | py | Runtime Error | 0 | 0 | 297 | import itertools
while 1:
n = input()
if n == 0: break
m = (n-1)/2
a = list(set([i**2%n for i in range(1,n)]))
l = len(a)
h = [0]*(m+1)
for i,j in itertools.combinations(a,2):
d = i - j
if 0 <= d <= m:
h[d] += 2
else:
h[min(d+n,n-d,-d)] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmp25e1ussx/tmph0h7ik35.py", line 16
print h[i]
^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s056720350 | p00142 | u633068244 | 1398336779 | Python | Python | py | Runtime Error | 0 | 0 | 431 | import itertools
r = 10001
s = int(r**0.5)
p = [1]*r
p[0] = 0
for i in range(s):
if p[i]:
p[2*i+1::i+1] = [0 for i in range(2*i+1,r,i+1)]
while 1:
n = input()
if n == 0: break
m = (n-1)/2
if p[n-1] == 1:
for i in range(m):
print 4
continue
a = sorted(list(set([i**2%n for i in range(1,n))))
h = [0]*(m+1)
for i,j in itertools.combinations(a,2):
h[min(j - i,n - j + i)] += 2
for i in range(1,m+1):
print h[i] | File "/tmp/tmppfbhwx25/tmpr64d87li.py", line 19
a = sorted(list(set([i**2%n for i in range(1,n))))
^
SyntaxError: closing parenthesis ')' does not match opening parenthesis '['
| |
s842392122 | p00143 | u032662562 | 1490428451 | Python | Python3 | py | Runtime Error | 0 | 0 | 858 | import numpy as np
def crossP(a, b, c, d):
e = b - a
f = c - d
g = c - a
A = np.matrix([[e.real,f.real],[e.imag, f.imag]])
B = np.matrix([[g.real],[g.imag]])
try:
C = np.linalg.solve(A, B)
except:
return(-9999+(-9999)*1j)
return(C[0,0]+C[1,0]*1j)
def rangeP(st):
return((0.0<=st.real<=1.0) and (0.0<=st.imag<=1.0))
if __name__ == '__main__':
n = int(input().strip())
for i in range(n):
[xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys] = map(int, input().strip().split())
a = xp1+yp1*1j
b = xp2+yp2*1j
c = xp3+yp3*1j
k = xk+yk*1j
s = xs+ys*1j
shut = 0
if rangeP(crossP(a,b,k,s)):
shut += 1
if rangeP(crossP(b,c,k,s)):
shut += 1
if rangeP(crossP(c,a,k,s)):
shut += 1
if shut == 1:
print("OK")
else:
print("NG") | Traceback (most recent call last):
File "/tmp/tmpybpgnh77/tmpi3ghht_q.py", line 18, in <module>
n = int(input().strip())
^^^^^^^
EOFError: EOF when reading a line
| |
s912087491 | p00146 | u647766105 | 1394649007 | Python | Python | py | Runtime Error | 0 | 0 | 1091 | #Lupin The 4th: O(2^n)
def f(a, b, visited):
w = W[visited] * 20
return abs(lengths[a] - lengths[b]) * (70 + w)
def solve():
cache = dict([((i, 0), (0, [i])) for i in xrange(n)])
def dfs(top, visited):
if (top, visited) in cache:
return cache[(top, visited)]
ret = (1 << 30, [-1])
for i in xrange(n):
if (visited >> i) & 1 == 1:
tmp = dfs(i, visited ^ (1 << i))
c = tmp[0] + f(top, i, visited)
if c < ret[0]:
ret = (c, tmp[1])
cache[(top, visited)] = (ret[0], ret[1] + [top])
return cache[(top, visited)]
mask = (1 << n) - 1
ret = (1 << 30, -1)
for i in xrange(n):
ret = min(ret, dfs(i, mask ^ (1 << i)))
return ret[1]
n = input()
num, lengths, weights = zip(*[map(int, raw_input().split()) for _ in xrange(n)])
cache = dict([((i, 0), 0) for i in xrange(n)])
W = [0] + [sum(weights[i] for i in xrange(n) if (b >> i) & 1 == 1)
for b in xrange(1, 1 << n)]
print " ".join(map(lambda i:str(num[i]), solve())) | File "/tmp/tmp8x3kvbub/tmpfez3ixms.py", line 31
print " ".join(map(lambda i:str(num[i]), solve()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s280352015 | p00147 | u912237403 | 1419088013 | Python | Python | py | Runtime Error | 0 | 0 | 690 | R = range(100)
M = [[2,5,2,2,2][i%5] for i in R]
Out = [-1] *100
P = [-1]*100
S = [-1]*17
Q = []
W = [0]*100
def stand(I, s):
n = M[I]
P[I] = -1
S[s:s+n] = [-1] * n
Out[I] = -1
return 1
def sit(I, s):
n = M[I]
P[I] = s
S[s:s+n] = [I] * n
Out.[I] = t+ 17*(I%2)+3*(I%3)+19
W[I] = t - I*5
return
def check(I):
n = M[I]
for s in range(17-n):
if S[s:s+n] == [-1]*n: return s
return -1
t = 0
c = 0
while t<100:
while t in Out:
I = Out.index(t)
c += stand(I, P[I])
if t<500 and t%5==0: Q.append(t/5)
while len(Q)>0:
s = check(Q[0])
if s==-1: break
sit(Q.pop(0), s)
t += 1
while 1:
try: print W[int(raw_input())]
except: break | File "/tmp/tmpoiqa95ek/tmpfl6jpsy8.py", line 20
Out.[I] = t+ 17*(I%2)+3*(I%3)+19
^
SyntaxError: invalid syntax
| |
s743093422 | p00148 | u759934006 | 1373403837 | Python | Python | py | Runtime Error | 0 | 0 | 129 | while True:
n = raw_input()
if not n:
break
else:
n = int(n)
print "3C{0:0>2}".format(n % 39) | File "/tmp/tmpud3rvdkf/tmpy12izkin.py", line 7
print "3C{0:0>2}".format(n % 39)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s260604318 | p00149 | u879226672 | 1427732406 | Python | Python | py | Runtime Error | 0 | 0 | 510 | def hantei(l):
if l >= 1.1:
return 'A'
elif 0.6 <= l < 1.1:
return 'B'
elif 0.2 <= l < 0.6:
return 'C'
elif 0.2 < l:
return 'D'
ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
try:
l,r = map(float,raw_input().split())
ls.append((l,r))
except EOFError:
break
for l,r in ls:
ldic[hantei(l)] += 1
rdic[hantei(r)] += 1
for L,R in zip(sorted(ldic),sorted(rdic)):
print L,R | File "/tmp/tmpn85_4uao/tmptw0ymafa.py", line 25
print L,R
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s074284244 | p00149 | u879226672 | 1427732497 | Python | Python | py | Runtime Error | 0 | 0 | 519 | def hantei(l):
if l >= 1.1:
return 'A'
elif 0.6 <= l < 1.1:
return 'B'
elif 0.2 <= l < 0.6:
return 'C'
elif 0.2 < l:
return 'D'
ldic = {'A':0, 'B':0, 'C':0, 'D':0}
rdic = {'A':0, 'B':0, 'C':0, 'D':0}
ls = []
while True:
try:
l,r = map(float,raw_input().split())
ls.append((l,r))
except EOFError:
break
for i,j in ls:
ldic[hantei(i)] += 1
rdic[hantei(j)] += 1
for L,R in zip(sorted(ldic),sorted(rdic)):
print L,R | File "/tmp/tmpdl38w4bo/tmp1rdev8h8.py", line 26
print L,R
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s878780104 | p00149 | u546285759 | 1483410645 | Python | Python3 | py | Runtime Error | 0 | 0 | 509 | ld, rd = [0, 0, 0, 0]. [0, 0, 0, 0]
while True:
try:
l, r = map(float, input().split())
if l < 0.2:
ld[3] += 1
elif l < 0.6:
ld[2] += 1
elif l < 1.1:
ld[1] += 1
else:
ld[0] += 1
if r < 0.2:
rd[3] += 1
elif r < 0.6:
rd[2] += 1
elif r < 1.1:
rd[1] += 1
else:
rd[0] += 1
except:
break
for l, r in zip(ld, rd):
print(l, r) | File "/tmp/tmpl4svv_gx/tmpgposa2si.py", line 1
ld, rd = [0, 0, 0, 0]. [0, 0, 0, 0]
^
SyntaxError: invalid syntax
| |
s886882147 | p00149 | u633068244 | 1395844616 | Python | Python | py | Runtime Error | 0 | 0 | 340 | ref = [1.1,0.6,0.2,0.0]
rank = [[0,0] for i in range(4)]
while True:
try:
eye = map(float, raw_input().split())
for i in range(2):
for j in range(4):
if eye[i] >= ref[j]: rank[j][i] += 1
break
except:
break
print " ".join(map(str, rank[i])) for i in range(4) | File "/tmp/tmpc9btodw1/tmpxned21ex.py", line 13
print " ".join(map(str, rank[i])) for i in range(4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s190543105 | p00150 | u957021183 | 1505713048 | Python | Python3 | py | Runtime Error | 0 | 0 | 1011 | # Aizu Problem 00150: Twin Prime
#
import sys, math, os, bisect
# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
sys.stdin = open("sample-input.txt", "rt")
def primes2(n):
""" Input n>=6, Returns a list of primes, 2 <= p < n """
n, correction = n-n%6+6, 2-(n%6>1)
sieve = [True] * (n//3)
for i in range(1,int(n**0.5)//3+1):
if sieve[i]:
k=3*i+1|1
sieve[ k*k//3 ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]
primes = primes2(10000)
while True:
n = int(input())
if n == 0:
break
idx = bisect.bisect_left(primes, n)
while True:
#if idx == len(primes):
# idx -= 1
if primes[idx] >= n:
idx -= 1
if primes[idx] - primes[idx - 1] == 2:
print(primes[idx - 1], primes[idx])
break
idx -= 1 | Traceback (most recent call last):
File "/tmp/tmp3xqsf4ay/tmpt02i9kv8.py", line 25, in <module>
n = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s449779531 | p00151 | u873482706 | 1436243302 | Python | Python | py | Runtime Error | 0 | 0 | 1999 | def f():
max_c = 0
c = 0
for h in range(n):
for w in range(n):
if grid[h][w] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
c = 0
for w in range(n):
for h in range(n):
if grid[h][w] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
c = 0
for p in range(n):
for a in range(n-p):
if grid[p+a][0+a] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
c = 0
for p in range(1,n):
for a in range(n-p):
if grid[0+a][p+a] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
for p in range(n):
for a in range(n-p):
if grid[p+a][n-1-a] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
c = 0
for p in range(n, -1, -1):
for a in range(p):
if grid[0+a][p-a] == 1:
c += 1
else:
if max_c < c:
max_c = c
c = 0
else:
if max_c < c:
max_c = c
c = 0
print max_c
while True:
n = input()
if n == 0: break
grid = [map(int, raw_input()) for i in range(n)]
f() | File "/tmp/tmp3qmhm6s6/tmpa7296t2t.py", line 81
print max_c
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s178499488 | p00152 | u078042885 | 1487793928 | Python | Python3 | py | Runtime Error | 0 | 0 | 331 | def score(x):
s=0;t=1
for _ in[0]*10:
a=2;b=3
if x[t]==10:a=1
elif x[t]+x[t+1]!=10:b=2
s+=sum(x[t:t+b]);t+=a
return x[0],s
while 1:
n=int(input())
if n==0:break
A=sorted([score(map(int,input().split())) for _ in [0]*n])
for a,b in sorted(A,key=lambda x:-x[1]):print(a,b) | Traceback (most recent call last):
File "/tmp/tmp3vo3i_ap/tmpps1re8go.py", line 11, in <module>
n=int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s587292230 | p00152 | u352394527 | 1529495816 | Python | Python3 | py | Runtime Error | 0 | 0 | 1589 | def get_point(info):
info.reverse()
acc = 0
NORMAL, SPARE, STRIKE, DOUBLE = 0, 1, 2, 3
flag = NORMAL
game_num = 0
while info:
if game_num != 9:
down_num1 = info.pop()
if down_num1 != 10:
down_num2 = info.pop()
if flag == SPARE:
acc += down_num1 * 2 + down_num2
elif flag == STRIKE:
acc += down_num1 * 2 + down_num2 * 2
elif flag == DOUBLE:
acc += down_num1 * 3 + down_num2 * 2
else:
acc += down_num1 + down_num2
if down_num1 + down_num2 == 10:
flag = SPARE
else:
flag = NORMAL
else:
if flag in (SPARE, STRIKE):
acc += down_num1 * 2
elif flag == DOUBLE:
acc += down_num1 * 3
else:
acc += down_num1
if flag in (STRIKE, DOUBLE):
flag = DOUBLE
else:
flag = STRIKE
game_num += 1
else:
down_num1, down_num2 = info.pop(), info.pop()
if flag == SPARE:
acc += down_num1 * 2 + down_num2
elif flag == STRIKE:
acc += down_num1 * 2 + down_num2 * 2
elif flag == DOUBLE:
acc += down_num1 * 3 + down_num2 * 2
else:
acc += down_num1 + down_num2
if info:
acc += info.pop()
return acc
while True:
m = int(input())
if m == 0:
break
score = [list(map(int, input().split())) for _ in range(m)]
score_mp = [(info[0], get_point(info[1:])) for info in score]
score.mpsort()
score_mp.sort(key=lambda x:-x[1])
for pair in score_mp:
print(*pair)
| Traceback (most recent call last):
File "/tmp/tmpueje_h3y/tmp4x20fejg.py", line 55, in <module>
m = int(input())
^^^^^^^
EOFError: EOF when reading a line
| |
s200098034 | p00153 | u912237403 | 1419160853 | Python | Python | py | Runtime Error | 0 | 0 | 930 | def In(): return map(int,raw_input().split())
def D(a,b): return ((a[0]-b[0])**2+(a[1]-b[1])**2)**.5
def side(a, b, c):
f = (c[1]-a[1])*(b[0]-a[0])-(b[1]-a[1])*(c[0]-a[0])
if f>0: return 1
elif f<0: return -1
else return 0
def isIn(x,p0,p1,p2):
f1 = side(p0,p1,x)
f2 = side(p1,p2,x)
f3 = side(p2,p0,x)
return (f1>=0 and f2>=0 and f3>=0) or (f1<=0 and f2<=0 and f3<=0)
def S(a,b,c): return abs(a[0]*(b[1]-c[1])+b[0]*(c[1]-a[1])+c[0]*(a[1]-b[1]))/2.0
def H(P1,P2,P3): return 2*S(P1,P2,P3)/D(P2,P3)
def check(P4,r,P1,P2,P3):
if all([D(P4,P1)<=r, D(P4,P2)<=r, D(P4,P3)<=r]): return 2
h1 = H(P4,P1,P2)
h2 = H(P4,P2,P3)
h3 = H(P4,P3,P1)
if isIn(P4,P1,P2,P3):
if all([h1>=r, h2>=r, h3>=r]): return 1
else:
if all([h1>r, h2>r, h3>r]): return 0
return 3
while 1:
P1 = In()
if P1[0]==P1[1]==0: break
P2 = In()
P3 = In()
P4 = In()
r = int(raw_input())
print 'dabc'[check(P4,r,P1,P2,P3)] | File "/tmp/tmpah0zmaol/tmpgbd5_rw1.py", line 7
else return 0
^^^^^^
SyntaxError: expected ':'
| |
s954211816 | p00154 | u873482706 | 1435574121 | Python | Python | py | Runtime Error | 19930 | 4240 | 591 | def f(i):
global soc, ans, ng
for n in range(m[i][1]+1):
soc += (m[i][0]*n)
if ng < soc:
soc -= m[i][0]*n
return
elif ng == soc:
ans += 1
soc -= m[i][0]*n
return
elif i < N-1:
f(i+1)
soc -= m[i][0]*n
while True:
N = int(raw_input())
if N == 0: break
m = [map(int, raw_input().split()) for i in range(N)]
g = [int(raw_input()) for i in range(input())]
soc = 0
ans = 0
for ng in g:
f(0)
print ans
ans = 0
soc = 0 | File "/tmp/tmp_68argjt/tmpece22x0p.py", line 25
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s703776143 | p00154 | u873482706 | 1435574197 | Python | Python | py | Runtime Error | 19920 | 4244 | 631 | import sys
sys.setrecursionlimit(20000)
def f(i):
global soc, ans, ng
for n in range(m[i][1]+1):
soc += (m[i][0]*n)
if ng < soc:
soc -= m[i][0]*n
return
elif ng == soc:
ans += 1
soc -= m[i][0]*n
return
elif i < N-1:
f(i+1)
soc -= m[i][0]*n
while True:
N = int(raw_input())
if N == 0: break
m = [map(int, raw_input().split()) for i in range(N)]
g = [int(raw_input()) for i in range(input())]
soc = 0
ans = 0
for ng in g:
f(0)
print ans
ans = 0
soc = 0 | File "/tmp/tmp0b3ezf7j/tmpvn4_wwcy.py", line 27
print ans
^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s588695774 | p00154 | u108432367 | 1344260724 | Python | Python | py | Runtime Error | 19930 | 5164 | 468 | #encoding: UTF-8
price = count = n = 0
def f(tc,tp):
global count
if tc == n:
if tp == price:
count += 1
else:
for i in range(l[tc][1]+1):
f(tc + 1,tp + (l[tc][0] * i))
n = int(raw_input())
l = []
while n != 0:
for i in range(n):
s = raw_input()
a = s.split(" ")
s = a[0]
ts = a[1]
tl = [int(s),int(ts)]
l.append(tl)
a = int(raw_input())
for i in range(a):
price = int(raw_input())
f(0,0)
print count
count = 0
n = int(raw_input()) | File "/tmp/tmpao5tm3ca/tmpl5jc65uk.py", line 25
print count
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s724646392 | p00154 | u779627195 | 1355919678 | Python | Python | py | Runtime Error | 19930 | 4264 | 636 | R = lambda:map(int, raw_input().split())
def solve(num, s, m):
c = 0
if m is len(a)-1:
#print num-s
if (num - s % a[len(a)-1][0]
and 0 <= num - s <= a[len(a)-1][0]*a[len(a)-1][1]): return 1
else: return 0
for i in xrange(a[m][1]+1):
#print a[m], i
c += solve(num, s+a[m][0]*i, m+1)
return c
while 1:
m = int(raw_input())
if not m: break
a = []
for i in xrange(m):
ss, zgok = R()
a.append((ss, zgok))
a.sort(reverse=True)
n = int(raw_input())
for i in xrange(n):
num = int(raw_input())
print solve(num, 0, 0) | File "/tmp/tmp9wqdj_2e/tmp6f49tsoi.py", line 25
print solve(num, 0, 0)
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s721046702 | p00154 | u633068244 | 1396204290 | Python | Python | py | Runtime Error | 0 | 0 | 114 | def f(n):
c=0
while n>1:
if n%2:n=3*n+1
else:n/=2
c+=1
print c
while 1:
n=input()
if n==0:break
f(n) | File "/tmp/tmpivjmd7zs/tmpe8iw_89p.py", line 7
print c
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s587120226 | p00154 | u633068244 | 1396204334 | Python | Python | py | Runtime Error | 0 | 0 | 114 | def f(n):
c=0
while n>1:
if n%2:n=3*n+1
else:n/=2
c+=1
print c
while 1:
n=input()
if n==0:break
f(n) | File "/tmp/tmp9ydn0gb2/tmp12qwm0gp.py", line 7
print c
^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
| |
s160525100 | p00155 | u811733736 | 1506915970 | Python | Python3 | py | Runtime Error | 0 | 0 | 2436 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
from heapq import heappush, heappop
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
node = len(G)
d = [float('inf')] * node
color = [WHITE] * node
p = [-1] * node
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(node):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(node):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (n+1) for _ in range(n+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
d = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if d <= 50.0:
G[b1][b2] = d
G[b2][b1] = d
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmpuv1lir2f/tmpmxgpymm0.py", line 81, in <module>
main(sys.argv[1:])
File "/tmp/tmpuv1lir2f/tmpmxgpymm0.py", line 43, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s421095769 | p00155 | u811733736 | 1506918436 | Python | Python3 | py | Runtime Error | 0 | 0 | 2401 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
node = len(G)
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(node):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(node):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
d = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if d <= 50.0:
G[b1][b2] = d
G[b2][b1] = d
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmp4knavu70/tmpolb9mo12.py", line 80, in <module>
main(sys.argv[1:])
File "/tmp/tmp4knavu70/tmpolb9mo12.py", line 42, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s104974451 | p00155 | u811733736 | 1506919196 | Python | Python3 | py | Runtime Error | 0 | 0 | 2454 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(101):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(101):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
d = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if d <= 50.0:
G[b1][b2] = d
G[b2][b1] = d
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
if s == g:
print(s)
continue
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmpimp0s4vi/tmpc23cf6gf.py", line 82, in <module>
main(sys.argv[1:])
File "/tmp/tmpimp0s4vi/tmpc23cf6gf.py", line 41, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s952271441 | p00155 | u811733736 | 1506921975 | Python | Python3 | py | Runtime Error | 0 | 0 | 2564 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(101):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(101):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
d = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if d <= 50.0:
G[b1][b2] = d
G[b2][b1] = d
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
if s == g:
print(s)
continue
if (not 1<= s <= 100) or (not 1<= g <= 100):
print('NA')
continue
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmp995wsipf/tmpn56vuoxp.py", line 85, in <module>
main(sys.argv[1:])
File "/tmp/tmp995wsipf/tmpn56vuoxp.py", line 41, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s672838366 | p00155 | u811733736 | 1506924360 | Python | Python3 | py | Runtime Error | 0 | 0 | 2609 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(101):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(101):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
d = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if d <= 50.0:
G[b1][b2] = d
G[b2][b1] = d
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
print('NA')
continue
if s == g:
print(s)
continue
if (not 1<= s <= 100) or (not 1<= g <= 100):
print('NA')
continue
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
if __name__ == '__main__':
main(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmps_g6rge6/tmppqv6v5ng.py", line 87, in <module>
main(sys.argv[1:])
File "/tmp/tmps_g6rge6/tmppqv6v5ng.py", line 41, in main
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s736377990 | p00155 | u811733736 | 1506924729 | Python | Python3 | py | Runtime Error | 0 | 0 | 2878 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(101):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(101):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
dist = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if dist <= 50.0:
G[b1][b2] = dist
G[b2][b1] = dist
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
if s == g:
print(s)
continue
if (not 1<= s <= 100) or (not 1<= g <= 100):
print('NA')
continue
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
def main2(args):
while True:
n = int(input())
if n == 0:
break
for _ in range(n):
b, x, y = map(int, input().split(' '))
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
print('NA')
if __name__ == '__main__':
main2(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmpbcpdc9ia/tmpplw8_d_n.py", line 100, in <module>
main2(sys.argv[1:])
File "/tmp/tmpbcpdc9ia/tmpplw8_d_n.py", line 86, in main2
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
| |
s557050558 | p00155 | u811733736 | 1506924845 | Python | Python3 | py | Runtime Error | 0 | 0 | 2847 | # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0155
"""
import sys
from sys import stdin
from math import sqrt
input = stdin.readline
def dijkstra(s, G):
BLACK, GRAY, WHITE = 0, 1, 2
d = [float('inf')] * 101
color = [WHITE] * 101
p = [-1] * 101
d[s] = 0
while True:
mincost = float('inf')
# ??\??????????????§??????????????¨?????????????????????u???????????????
for i in range(101):
if color[i] != BLACK and d[i] < mincost: # S????±???????????????????S??¨??\?¶?????????????????????????????????????????°???????????????????
mincost = d[i]
u = i # u??????????????????ID
if mincost == float('inf'):
break
color[u] = BLACK # ?????????u???S????±???????????????´???
for v in range(101):
if color[v] != BLACK and G[u][v] != float('inf'):
# v????????????????????????????????°??????S???????????£???u????????????????????????????????????????????°??????????????±??§??´??°??????
if d[u] + G[u][v] < d[v]:
d[v] = d[u] + G[u][v]
p[v] = u
color[v] = GRAY
return d, p
def main(args):
while True:
n = int(input())
if n == 0:
break
G = [[float('inf')] * (100+1) for _ in range(100+1)]
data = []
for _ in range(n):
b, x, y = map(int, input().split(' '))
data.append([b, x, y])
for i in range(n):
b1, x1, y1 = data[i]
for j in range(n):
b2, x2, y2 = data[j]
if b1 == b2:
continue
dist = sqrt((x1 - x2)**2 + (y1 - y2)**2)
if dist <= 50.0:
G[b1][b2] = dist
G[b2][b1] = dist
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
if s == g:
print(s)
continue
if (not 1<= s <= 100) or (not 1<= g <= 100):
print('NA')
continue
d, p = dijkstra(s, G)
if d[g] == float('inf'):
print('NA')
else:
path = [g]
while p[g] != s:
path.append(p[g])
g = p[g]
path.append(s)
rev = path[::-1]
print(' '.join(map(str, rev)))
def main2(args):
while True:
n = int(input())
if n == 0:
break
for _ in range(n):
input()
m = int(input())
for _ in range(m):
s, g = map(int, input().split(' '))
print('NA')
if __name__ == '__main__':
main2(sys.argv[1:]) | Traceback (most recent call last):
File "/tmp/tmpzk997_jw/tmpx747z_dj.py", line 100, in <module>
main2(sys.argv[1:])
File "/tmp/tmpzk997_jw/tmpx747z_dj.py", line 86, in main2
n = int(input())
^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: ''
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.