s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
stringlengths
1
5
memory
stringlengths
1
7
code_size
stringlengths
1
6
code
stringlengths
1
539k
s935502249
p01101
u226888928
1523580647
Python
Python3
py
Runtime Error
0
0
322
while true: (n,m) = map(int,input().split()) if n == 0 && m == 0: break is = list(map(int, input().split())) best = max [ is[i] + is[j] if not ( i == j) and is[i] + is[j] <= k else -1 for i in range(0:n) for j in range(0:n) ] if(best < 0): print("NONE") else: print(best)
s557885448
p01101
u226888928
1523580668
Python
Python3
py
Runtime Error
0
0
323
while true: (n,m) = map(int,input().split()) if n == 0 and m == 0: break is = list(map(int, input().split())) best = max [ is[i] + is[j] if not ( i == j) and is[i] + is[j] <= k else -1 for i in range(0:n) for j in range(0:n) ] if(best < 0): print("NONE") else: print(best)
s104385294
p01101
u063056051
1526457521
Python
Python3
py
Runtime Error
0
0
428
n,m=map(int,raw_input().split()) while n!=0 and m!=0: ok=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=list[j]+list[k] if tmp>max and tmp<=m: ok=1 max=tmp if ok==1: print(max) else: print("NONE") n,m=map(int,raw_input().split())
s819131407
p01101
u063056051
1526457909
Python
Python3
py
Runtime Error
0
0
426
n,m=map(int,raw_input().split()) while n!=0 and m!=0: ok=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=list[j]+list[k] if tmp>max and tmp<=m: ok=1 max=tmp if ok==1: print(max) else: print("NONE") n,m=map(int,raw_input().split())
s218948014
p01101
u063056051
1526458255
Python
Python3
py
Runtime Error
0
0
424
n,m=map(int,raw_input().split()) while n>0 and m>0: ok=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=list[j]+list[k] if tmp>max and tmp<=m: ok=1 max=tmp if ok==1: print(max) else: print("NONE") n,m=map(int,raw_input().split())
s400702249
p01101
u810922275
1526459021
Python
Python
py
Runtime Error
0
0
560
import numpy as np ans=[] for i in range(50000): n,m=map(int,input().split()) if n==0 and m==0: break else: A=list(map(int,input().split(' '))) sum=0 max=0 for j in range(len(A)): for k in range(len(A)): if j!=k: sum=A[j]+A[k] if sum>=max and sum<=m: max=sum if max==0: max="NONE" ans.append(max) for i in range(len(ans)): if ans[i]!=0: print(ans[i]) else: break
s792057449
p01101
u810922275
1526459182
Python
Python3
py
Runtime Error
0
0
560
import numpy as np ans=[] for i in range(50000): n,m=map(int,input().split()) if n==0 and m==0: break else: A=list(map(int,input().split(' '))) sum=0 max=0 for j in range(len(A)): for k in range(len(A)): if j!=k: sum=A[j]+A[k] if sum>=max and sum<=m: max=sum if max==0: max="NONE" ans.append(max) for i in range(len(ans)): if ans[i]!=0: print(ans[i]) else: break
s994215760
p01101
u063056051
1526459647
Python
Python3
py
Runtime Error
0
0
530
max1=[] ok1=[0] n,m=map(int,raw_input().split()) while n>0 and m>0: ie=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=list[j]+list[k] if tmp>max and tmp<=m: max=tmp ok1.insert(ie,1) max1.insert(ie,max) n,m=map(int,raw_input().split()) ie+=1 for i in range(len(max1)-1,-1,-1): if ok1[i]==1: print(max1[i]) else: print("NONE")
s041567339
p01101
u810098703
1526459858
Python
Python
py
Runtime Error
0
0
704
#include<stdio.h> #define MAX 2000000 int select(int S[],int n,int max){ int ans=0; int temp; for(int i = 0;i<n;i++){ for(int j = i+1;j<n;j++){ temp = S[i]+S[j]; if(temp <= max && ans <= temp){ ans = temp; } } } return ans; } int main(){ int n; int a; int m; int k =0; int ans[100000]; int S[MAX]; while(1){ scanf("%d",&n); scanf("%d",&m); if(n==0 && m == 0){ break; } for(int i = 0;i<n;i++){ scanf("%d",&a); S[i] = a; } ans[k] = select(S,n,m); k++; } for(int i = 0;i<k;i++){ if(ans[i]==0){ printf("NONE\n"); }else{ printf("%d\n",ans[i]); } } return 0; }
s241022505
p01101
u063056051
1526459903
Python
Python3
py
Runtime Error
0
0
539
max1=[] ok1=[0] n,m=map(int,raw_input().split()) while n>0 and m>0: tmp=0 ie=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=list[j]+list[k] if tmp>max and tmp<=m: max=tmp ok1.insert(ie,1) max1.insert(ie,max) n,m=map(int,raw_input().split()) ie+=1 for i in range(len(max1)-1,-1,-1): if ok1[i]==1: print(max1[i]) else: print("NONE")
s430473118
p01101
u196653484
1526459979
Python
Python3
py
Runtime Error
0
0
429
maxs=[] while(True): max=0 b=list(map(int,input().split())) n=b[0] m=b[1] if(n == 0 and m == 0): break a=list(map(int,input().split())) for i in range(n): for j in range(i+1,n): sum=a[i]+a[j] if(sum>max and sum<m): max=sum maxs.append(max) for i in maxs: if maxs[i]==0: print("NONE") else: print(maxs[i])
s749984458
p01101
u684325232
1526460192
Python
Python3
py
Runtime Error
0
0
377
s=[] cnt=0 while 1: max=0 n,m =map(int,input().split()) l=list(map(int,input().split())) if n==0 and m==0: break for i in range(len(l)): for j in range(len(l)): if max<l[i]+l[j] and i!=j and m>=l[i]+l[j]: max=l[i]+l[j] if max==0: s+=["NONE"] else: s+=[max] for x in s: print(x)
s971016170
p01101
u684325232
1526460251
Python
Python3
py
Runtime Error
0
0
377
s=[] cnt=0 while 1: max=0 n,m =map(int,input().split()) l=list(map(int,input().split())) if n==0 and m==0: break for i in range(len(l)): for j in range(len(l)): if max<l[i]+l[j] and i!=j and m>=l[i]+l[j]: max=l[i]+l[j] if max==0: s+=["NONE"] else: s+=[max] for x in s: print(x)
s903737422
p01101
u196653484
1526460371
Python
Python3
py
Runtime Error
0
0
415
maxs=[] while(True): max=-1 b=list(map(int,input().split())) n=b[0] m=b[1] if(n == 0 and m == 0): break a=list(map(int,input().split())) for i in range(n): for j in range(i+1,n): sum=a[i]+a[j] if(sum>max and sum=<m): max=sum maxs.append(max) for i in maxs: if i==-1: print("NONE") else: print(i)
s529016845
p01101
u063056051
1526460736
Python
Python3
py
Runtime Error
0
0
596
max1=[] ok1=[0] n,m=map(int,raw_input().split()) while n>0 and m>0: ok=0 ie=0 list=map(int,raw_input().split()) if list[0]<m: max=list[0] for j in range(len(list)-1): for k in range(1,len(list)): tmp=0 tmp=list[j]+list[k] if tmp>max and tmp<=m: max=tmp ok=1 max1.insert(ie,max) n,m=map(int,raw_input().split()) ie+=1 if ok==1: ok1.insert(ie,1) print(ok1) for i in range(len(max1)-1,-1,-1): if ok1[i]==1: print(max1[i]) else: print("NONE")
s814157856
p01101
u063056051
1526895412
Python
Python3
py
Runtime Error
0
0
509
A=map(int,input().split()) n=int(A[0]) m=int(A[1]) max=[] k=0 while n>0 and m>0: B=[0 for i in range(n)] B=input().split() for i in range(n): B[i]=int(B[i]) ma=0 for i in range(n): for j in range(i+1,n): x=0 x=B[i]+B[j] if ma<x and x<=m: ma=x max.append(ma) A=input().split() n=int(A[0]) m=int(A[1]) k+=1 for i in range(k): if max[i]>0: print(max[i]) else: print("NONE")
s877825546
p01101
u063056051
1526895510
Python
Python3
py
Runtime Error
0
0
518
A=[0 for i in range(2)] A=(int,input().split()) n=A[0] m=A[1] max=[] k=0 while n>0 and m>0: B=[0 for i in range(n)] B=input().split() for i in range(n): B[i]=int(B[i]) ma=0 for i in range(n): for j in range(i+1,n): x=0 x=B[i]+B[j] if ma<x and x<=m: ma=x max.append(ma) A=input().split() n=int(A[0]) m=int(A[1]) k+=1 for i in range(k): if max[i]>0: print(max[i]) else: print("NONE")
s782731924
p01101
u146816547
1527782512
Python
Python
py
Runtime Error
0
0
329
while True: n, m = map(int, raw_input().split()) if n == 0 and m == 0: break a = [int(raw_input()) for _ in range(n)] ans = -1 for i in range(n-1): for j in range(i+1, n): if a[i] + a[j] <= m: ans = max(ans, a[i] + a[j]) print "NONE" if ans == -1 else ans
s908329742
p01102
u328199937
1555828691
Python
Python3
py
Runtime Error
0
0
1564
while True: s1 = input() if s1 == ".": break s2 = input() listed_s1 = [[]] listed_s2 = [[]] start = 0 now = 0 for i in range(len(s1)): if s1[i] == "\"" and not start: listed_s1.append([]) now += 1 start = 1 listed_s1[now].append(s1[i]) elif s1[i] == "\"" and start: listed_s1[now].append(s1[i]) listed_s1.append([]) now += 1 start = 0 else: listed_s1[now].append(s1[i]) now = 0 for i in range(len(s2)): if s2[i] == "\"" and not start: listed_s2.append([]) now += 1 start = 1 listed_s2[now].append(s2[i]) elif s2[i] == "\"" and start: listed_s2[now].append(s2[i]) listed_s2.append([]) now += 1 start = 0 else: listed_s2[now].append(s2[i]) fist_wrong = 0 ans = "IDENTICAL" for i in range(min(len(listed_s1), len(listed_s2))): if listed_s1[i] != listed_s2[i]: if listed_s1[i][0] == "\"" and listed_s2[i][-1] == "\"" and listed_s2[i][0] == "\"" and listed_s2[i][-1] == "\"": if fist_wrong: ans = "DIFFERENT" else: fist_wrong = 1 ans = "CLOSE" else: ans = "DIFFERENT" if ans == "DIFFERENT": break if len(listed_s1) != len(listed_s2): ans = "DIFEERENT" print(ans)
s643598020
p01102
u328199937
1555828750
Python
Python3
py
Runtime Error
0
0
1564
while True: s1 = input() if s1 == ".": break s2 = input() listed_s1 = [[]] listed_s2 = [[]] start = 0 now = 0 for i in range(len(s1)): if s1[i] == "\"" and not start: listed_s1.append([]) now += 1 start = 1 listed_s1[now].append(s1[i]) elif s1[i] == "\"" and start: listed_s1[now].append(s1[i]) listed_s1.append([]) now += 1 start = 0 else: listed_s1[now].append(s1[i]) now = 0 for i in range(len(s2)): if s2[i] == "\"" and not start: listed_s2.append([]) now += 1 start = 1 listed_s2[now].append(s2[i]) elif s2[i] == "\"" and start: listed_s2[now].append(s2[i]) listed_s2.append([]) now += 1 start = 0 else: listed_s2[now].append(s2[i]) fist_wrong = 0 ans = "IDENTICAL" for i in range(min(len(listed_s1), len(listed_s2))): if listed_s1[i] != listed_s2[i]: if listed_s1[i][0] == "\"" and listed_s2[i][-1] == "\"" and listed_s2[i][0] == "\"" and listed_s2[i][-1] == "\"": if fist_wrong: ans = "DIFFERENT" else: fist_wrong = 1 ans = "CLOSE" else: ans = "DIFFERENT" if ans == "DIFFERENT": break if len(listed_s1) != len(listed_s2): ans = "DIFEERENT" print(ans)
s447634745
p01102
u260980560
1500995686
Python
Python3
py
Runtime Error
0
0
357
while 1: s1 = input().split('"') if s1 is '.': break s2 = input().split('"') if len(s1) != len(s2): print("DIFFERENT") continue r = [0]*2 for i in range(len(s1)): if s1[i] != s2[i]: r[i%2] += 1 if [0,1]<r: print("DIFFERENT") else: print(["IDENTICAL","CLOSE"][r[1]])
s099659158
p01102
u009961299
1502675182
Python
Python3
py
Runtime Error
0
0
1138
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re from typing import List def rdp_connect() -> bool: global s1, s2 s1 = input() if s1 == '.': return False s2 = input() return True def rdp_token(s: str) -> List[str]: res = [] while s: match = re.match(r'[a-zA-Z0-9;]+', s) if match: res.append(s[:match.end()]) s = s[match.end():] continue match = re.match(r'"[^"]*"', s) if match: res.append(s[:match.end()-1]) s = s[match.end():] continue return res def rdp_check() -> bool: l1 = rdp_token(s1) l2 = rdp_token(s2) if len(l1) != len(l2): return False flag = True for t1, t2 in zip(l1, l2): if t1 == t2: continue if t1[0] == t2[0] == '"' and flag: flag = False else: return False return True if __name__ == '__main__': while rdp_connect(): if s1 == s2: print('IDENTICAL') elif rdp_check(): print('CLOSE') else: print('DIFFERENT')
s604652225
p01102
u009961299
1502675331
Python
Python3
py
Runtime Error
0
0
1152
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import re from typing import List def rdp_connect() -> bool: global s1, s2 s1 = input() if s1 == '.': return False s2 = input() return True def rdp_token(s: str) -> List[str]: res = [] while s: match = re.match(r'[a-zA-Z0-9;]+', s) if match: res.append(s[:match.end()]) s = s[match.end():] continue match = re.match(r'"[^"]*"', s) if match: res.append(s[:match.end()-1]) s = s[match.end():] continue break return res def rdp_check() -> bool: l1 = rdp_token(s1) l2 = rdp_token(s2) if len(l1) != len(l2): return False flag = True for t1, t2 in zip(l1, l2): if t1 == t2: continue if t1[0] == t2[0] == '"' and flag: flag = False else: return False return True if __name__ == '__main__': while rdp_connect(): if s1 == s2: print('IDENTICAL') elif rdp_check(): print('CLOSE') else: print('DIFFERENT')
s326062663
p01102
u684325232
1526460925
Python
Python3
py
Runtime Error
0
0
281
s=[] while 1: l1=list(input().split()) if l1==".": break l2=list(input().split()) if l1==l2: s+=["INDENTCAL"] elif len(set(l1+l2))==1: s+=["CLODSE"] else: s+=["DIFFERENT"] print(s)
s316551929
p01102
u196653484
1526462092
Python
Python3
py
Runtime Error
0
0
634
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") for i in range(len(a)): if(i%2==0): del(a[i]) for i in range(len(b)): if(i%2==0): del(b[i]) count=0 for i,j in zip(a,b): for k,l in zip(a[i],b[j]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s696720248
p01102
u196653484
1526462362
Python
Python3
py
Runtime Error
0
0
522
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i,j in zip(range(len(a)),range(len(b))): for k,l in zip(a[2*i+1],b[2*j+1]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s896106006
p01102
u196653484
1526462403
Python
Python3
py
Runtime Error
0
0
526
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i,j in zip(range(len(a)/2),range(len(b)/2)): for k,l in zip(a[2*i+1],b[2*j+1]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s456617712
p01102
u196653484
1526462528
Python
Python3
py
Runtime Error
0
0
517
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i,j in zip(range(len(a)),range(len(b)): for k,l in zip(a[2*i],b[2*j]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s010518196
p01102
u196653484
1526462601
Python
Python3
py
Runtime Error
0
0
496
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i in range(len(a)): for k,l in zip(a[2*i],b[2*i]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s469041876
p01102
u196653484
1526462745
Python
Python3
py
Runtime Error
0
0
503
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i in range(int(len(a)/2)): for k,l in zip(a[2*i],b[2*i]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s779939186
p01102
u196653484
1526463317
Python
Python3
py
Runtime Error
0
0
510
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i in range(0,int(len(a)/2)): for k,l in zip(a[2*i+1],b[2*i+1]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s604211354
p01102
u196653484
1526463488
Python
Python3
py
Runtime Error
0
0
502
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count=0 for i in range(int(len(a)/2)): for k,l in zip(a[2*i+1],b[2*i+1]): if(k!=l): count+=1 if count==0: results.append(0) elif count==1: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s535690891
p01102
u064313887
1526463858
Python
Python3
py
Runtime Error
0
0
944
while 1: key = 0 s1 = input() if s1 == '.': break s2 = input() if len(s1) == len(s2): for i in range(len(s1)): if s1[i] != s2[i]: key += 1 if key >= 2: output.append('DIFFERENT') break if key == 0: output.append('IDENTICAL') elif key == 1: output.append('CLOSE') else: if len(s1) > len(s2): d = len(s1) - len(s2) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('DIFFERENT') break else: d = len(s2) - len(s1) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('DIFFERENT') break for i in range(len(output)): print(output[i])
s306416973
p01102
u064313887
1526463866
Python
Python3
py
Runtime Error
0
0
944
while 1: key = 0 s1 = input() if s1 == '.': break s2 = input() if len(s1) == len(s2): for i in range(len(s1)): if s1[i] != s2[i]: key += 1 if key >= 2: output.append('DIFFERENT') break if key == 0: output.append('IDENTICAL') elif key == 1: output.append('CLOSE') else: if len(s1) > len(s2): d = len(s1) - len(s2) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('DIFFERENT') break else: d = len(s2) - len(s1) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('DIFFERENT') break for i in range(len(output)): print(output[i])
s105305521
p01102
u064313887
1526464086
Python
Python3
py
Runtime Error
0
0
935
while 1: key = 0 s1 = input() if s1 == '.': break s2 = input() if len(s1) == len(s2): for i in range(len(s1)): if s1[i] != s2[i]: key += 1 if key >= 2: output.append('DIFFERENT') break if key == 0: output.append('IDENTICAL') elif key == 1: output.append('CLOSE') else: if len(s1) > len(s2): d = len(s1) - len(s2) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('CLOSE') break else: d = len(s2) - len(s1) if d >= 2: output.append('DIFFERENT') break elif d == 1: output.append('CLOSE') break for i in range(len(output)): print(output[i])
s037838561
p01102
u848218390
1526465905
Python
Python3
py
Runtime Error
0
0
600
while 1: s1 = input().split('\"') if s1[0] == '.': break s2 = input().split('\"') jdg = 1 cnt_d = if len(s1) != len(s2): print("DIFFERENT") else: l = len(s1) i = 0 while i < l: if s1[i] != s2[i]: cnt_d += 1 if cnt_d == 1 and i % 2 == 1: jdg = 1 else: jdg = 0 break i += 1 if jdg == 1 and cnt_d == 1: print("CLOSE") elif jdg == 0 or cnt_d > 1: print("DIFFERENT") else: print("IDENTICAL")
s573836667
p01102
u196653484
1526532287
Python
Python3
py
Runtime Error
0
0
831
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 print(a) print(b) for i in range(int(len(a))): if(i%2==1): for k,l in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s209724227
p01102
u196653484
1526532329
Python
Python3
py
Runtime Error
0
0
799
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 for i in range(int(len(a))): if(i%2==1): for k,l in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s222679766
p01102
u196653484
1526532533
Python
Python3
py
Runtime Error
0
0
769
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 for i in range(int(len(a))): if(i%2==1): for k,l in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s695740990
p01102
u196653484
1526532631
Python
Python3
py
Runtime Error
0
0
771
results=[] while True: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 for i in range(int(len(a))): if(i%2==1): for (k,l) in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s742791736
p01102
u196653484
1526532921
Python
Python3
py
Runtime Error
0
0
793
results=[] while True: a=list(map(input().split("\""))) if a[0]==".": break b=list(map(input().split("\""))) count1=0 count2=0 for i in range(int(len(a))): if(i%2==1): for (k,l) in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s849933635
p01102
u196653484
1526533178
Python
Python3
py
Runtime Error
0
0
793
results=[] while True: a=list(map(input().split("\""))) if a[0]==".": break b=list(map(input().split("\""))) count1=0 count2=0 for i in range(int(len(a))): if(i%2==1): for (k,l) in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s747146611
p01102
u196653484
1526533355
Python
Python3
py
Runtime Error
0
0
763
results=[] while 1: a=input().split("\"") if a[0]==".": break b=input().split("\"") count1=0 count2=0 for i in range(len(a)): if(i%2==1): for (k,l) in zip(a[i],b[i]): if(k!=l): count1+=1 else: for k,l in zip(a[i],b[i]): if(k!=l): count2+=1 if len(a) != len(b): results.append(2) else: if count1==0 and count2==0: results.append(0) elif count1==1 and count2==0: results.append(1) else: results.append(2) for i in results: if i==0: print("IDENTICAL") if i==1: print("CLOSE") if i==2: print("DIFFERENT")
s570542671
p01102
u564105430
1526534313
Python
Python3
py
Runtime Error
0
0
450
while 1: s1=input().split('"') if s1==".": break s2=input().split('"') cnt1=0 cnt2=0 i=0 if len(s1)!=len(s2): print("DIFFERENT") else: while i<len(s1): if s1[i]==s2[i]: cnt1+=1 elif s1[i]!=s2[i] and i%2==0: print("DIFFERENT") break elif s1[i]!=s2[i] and i%2!=0: cnt2+=1 if cnt2>1: print("DIFFERENT") break i+=1 if cnt2==1: print("CLOSE") if cnt1==len(s1): print("IDENTICAL")
s518008299
p01102
u063056051
1526985132
Python
Python3
py
Runtime Error
0
0
481
while 1: list1=input().split('"') if len(list1)==1 and list1[0]=='.': break list2=input().split('"') cnt=0 flag1=1 flag2=0 if len(list1)!=len(list2): flag1=0 else: i=0 while i<len(list1): if list1[i]==list2[i]: elif i%2==0: flag1=0 flag2=1 break else: cnt+=1 if cnt>1: flag1=0 break i+=1 if flag1==0 and cnt==1 and flag2=0: print("CLOSE") elif flag==1: print("IDENTICAL") else: print("DEFFERENT")
s459655107
p01102
u063056051
1526985251
Python
Python3
py
Runtime Error
0
0
712
while 1: list1=input().split('"') if len(list1)==1 and list1[0]==".": break list2=input().split('"') c1=0 c2=0 flag=0 if len(list1)!=len(list2): print("DIFFERENT") else: i=0 while i<len(list1): if list1[i]==list2[i]: c1+=1 elif i%2==0: print("DIFFERENT") flag=1 break else: c2+=1 if c2>1: print("DIFFERENT") break i+=1 if flag==0 and t2==1: print("CLOSE") if c1==len(list1): print("IDENTICAL")
s667316633
p01102
u063056051
1526985266
Python
Python3
py
Runtime Error
0
0
694
while 1: list1=input().split('"') if list1[0]==".": break list2=input().split('"') c1=0 c2=0 flag=0 if len(list1)!=len(list2): print("DIFFERENT") else: i=0 while i<len(list1): if list1[i]==list2[i]: c1+=1 elif i%2==0: print("DIFFERENT") flag=1 break else: c2+=1 if c2>1: print("DIFFERENT") break i+=1 if flag==0 and t2==1: print("CLOSE") if c1==len(list1): print("IDENTICAL")
s047715730
p01102
u826549974
1526991234
Python
Python3
py
Runtime Error
0
0
1848
while(1): a = input() if(a == '.'): break b = input() n = len(a) m = len(b) l = 0; flag = 0 idx_dif = 0 error_cou = 0 while(1): if(l >= n-1 or l+idx_dif >= m-1): flag = 2 if(flag == 0): for i in range(l,n): if(a[i] == '\"'): for j in range(l+idx_dif,m): if(b[j] == '\"'): if(a[l:i] == b[l+idx_dif:j]): idx_dif = j-i l = i+1 flag = 1 else: flag = 2 break elif(i == n-1): if(a[l:i] != b[l+idx_dif:m-1]): flag = 2 else: l = n-1 break if(flag != 0): break elif(flag == 1): for i in range(l,n): if(a[i] == '\"'): for j in range(l+idx_dif,m): if(b[j] == '\"'): if(a[l:i] != b[l+idx_dif:j]): error_cou += 1 idx_dif = j-i l = i+1 flag = 0 break if(j == m-1): flag = 2 break if(flag != 1): break if(flag == 2): break if(l >= n-1 or l+idx_dif >= m-1): break if(error_cou >= 2 or flag == 2): print("DIFFERENT") elif(error_cou == 1): print("CLOSE") elif(error_cou == 0): print("IDENTICAL")
s171650124
p01102
u826549974
1526991380
Python
Python3
py
Runtime Error
0
0
1872
while(1): a = input() if(a == '.'): break b = input() n = len(a) m = len(b) l = 0; flag = 0 idx_dif = 0 error_cou = 0 while(1): if(l >= n-1 or l+idx_dif >= m-1): flag = 2 if(flag == 0): for i in range(l,n): if(a[i] == '\"'): for j in range(l+idx_dif,m): if(b[j] == '\"'): if(a[l:i] == b[l+idx_dif:j]): idx_dif = j-i l = i+1 flag = 1 else: flag = 2 break elif(i == n-1): if(a[l:i] != b[l+idx_dif:m-1]): flag = 2 else: l = n-1 break if(flag != 0): break elif(flag == 1): for i in range(l,n): if(a[i] == '\"'): for j in range(l+idx_dif,m): if(b[j] == '\"'): if(a[l:i] != b[l+idx_dif:j]): error_cou += 1 idx_dif = j-i l = i+1 flag = 0 break if(j == m-1): flag = 2 break if(flag != 1): break if(flag == 2): break if(l >= n-1 or l+idx_dif >= m-1 or error_cou == 2): break if(error_cou >= 2 or flag == 2): print("DIFFERENT") elif(error_cou == 1): print("CLOSE") elif(error_cou == 0): print("IDENTICAL")
s919927742
p01102
u826549974
1526994358
Python
Python3
py
Runtime Error
0
0
2116
while(1): a = input() if(a == '.'): break b = input() n = len(a) m = len(b) l = 0; flag = 0 idx_dif = 0 error_cou = 0 while(1): if(l >= n-1 or l+idx_dif >= m-1): flag = 2 if(flag == 0): for i in range(l,n): if(a[i] == '\"'): #for j in range(l+idx_dif,m): #if(b[j] == '\"'): #if(a[l:i] == b[l+idx_dif:j]): if(i+idx_dif < m): if(a[l:i] == b[l+idx_dif:i+idx_dif]): l = i+1 flag = 1 else: flag = 2 break #idx_dif = j-i #l = i+1 #flag = 1 #else: #flag = 2 #break elif(i == n-1): if(a[l:i] != b[l+idx_dif:m-1]): flag = 2 else: l = n-1 break if(flag != 0): break elif(flag == 1): for i in range(l,n): if(a[i] == '\"'): for j in range(l+idx_dif,m): if(b[j] == '\"'): if(a[l:i] != b[l+idx_dif:j]): error_cou += 1 idx_dif = j-i l = i+1 flag = 0 break if(j == m-1): flag = 2 break if(flag != 1): break if(flag == 2): break if(l >= n-1 or l+idx_dif >= m-1): break if(error_cou >= 2 or flag == 2): print("DIFFERENT") elif(error_cou == 1): print("CLOSE") elif(error_cou == 0): print("IDENTICAL")
s932565592
p01102
u810922275
1527034214
Python
Python
py
Runtime Error
0
0
658
import numpy as np A1=[] A2=[] ans=[] for i in range(100): cnt=0 S1=input("プログラム1:") if S1=='.': break S2=input("プログラム2:") A1=S1.split('"') A2=S2.split('"') if len(A1)==len(A2): for j in range(len(A1)): if j%2!=0: if A1[j]!=A2[j]: cnt=cnt+1 else: if A1[j]!=A2[j]: cnt=cnt+10000 else: cnt=cnt+10000 if cnt>1: ans.append("DIFERENT") elif cnt==1: ans.append("CLOSE") else: ans.append("IDENTICAL") for i in range(len(ans)): print(ans[i])
s877658451
p01102
u810922275
1527034233
Python
Python
py
Runtime Error
0
0
639
A1=[] A2=[] ans=[] for i in range(100): cnt=0 S1=input("プログラム1:") if S1=='.': break S2=input("プログラム2:") A1=S1.split('"') A2=S2.split('"') if len(A1)==len(A2): for j in range(len(A1)): if j%2!=0: if A1[j]!=A2[j]: cnt=cnt+1 else: if A1[j]!=A2[j]: cnt=cnt+10000 else: cnt=cnt+10000 if cnt>1: ans.append("DIFERENT") elif cnt==1: ans.append("CLOSE") else: ans.append("IDENTICAL") for i in range(len(ans)): print(ans[i])
s429414688
p01102
u055885332
1527047803
Python
Python3
py
Runtime Error
0
0
463
#16D8101014F 久留米 竜之介 Python3 #a=[] while(True): i=0 tmp=0 a=input().split('"') aL=a.len() b=input().split('"') bL=b.len() if aL != bL: print("DIFFELENT") else: while(True): if a[i] != b[i]: print("DIFFERENT") break elif i > aL-2: if tmp==1: print("CLOSE") break else: print("IDENTICAL") break elif a[i+1] != b[i+1]: if tmp==1: print("DIFFERENT") break else: tmp=1 i +=2
s632167684
p01102
u055885332
1527047900
Python
Python3
py
Runtime Error
0
0
461
#16D8101014F 久留米 竜之介 Python3 #a=[] while(True): i=0 tmp=0 a=input().split('"') aL=len(a) b=input().split('"') bL=len(b) if aL != bL: print("DIFFELENT") else: while(True): if a[i] != b[i]: print("DIFFERENT") break elif i > aL-2: if tmp==1: print("CLOSE") break else: print("IDENTICAL") break elif a[i+1] != b[i+1]: if tmp==1: print("DIFFERENT") break else: tmp=1 i +=2
s972560515
p01102
u055885332
1527048042
Python
Python3
py
Runtime Error
0
0
487
#16D8101014F 久留米 竜之介 Python3 #a=[] while(True): i=0 tmp=0 a=input().split('"') aL=len(a) b=input().split('"') bL=len(b) if a[0]==".": break if aL != bL: print("DIFFELENT") else: while(True): if a[i] != b[i]: print("DIFFERENT") break elif i > aL-2: if tmp==1: print("CLOSE") break else: print("IDENTICAL") break elif a[i+1] != b[i+1]: if tmp==1: print("DIFFERENT") break else: tmp=1 i +=2
s464685599
p01103
u260980560
1500996475
Python
Python3
py
Runtime Error
0
0
914
while 1: d, w = map(int, input().split()) if d == w == 0: break E = [[*map(int, input().split())] for i in range(d)] ans = 0 for x2 in range(d): for y2 in range(w): for x1 in range(x2-1): for y1 in range(y2-1): # [x1, x2] x [y1, y2] co = 10**18 for x in range(x1, x2+1): co = min(co, E[x][y1], E[x][y2]) for y in range(y1, y2+1): co = min(co, E[x1][y], E[x2][y]) ci = 0 cnt = 0 for x in range(x1+1, x2): for y in range(y1+1, y2): ci = max(ci, E[x][y]) cnt += E[x][y] if ci < co: ans = max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt) print(ans)
s281140338
p01103
u260980560
1500996567
Python
Python3
py
Runtime Error
0
0
872
while 1: d, w = map(int, input().split()) if d == w == 0: break E = [[*map(int, input().split())] for i in range(d)] ans = 0 for x2 in range(d): for y2 in range(w): for x1 in range(x2-1): for y1 in range(y2-1): co = 10**18 for x in range(x1, x2+1): co = min(co, E[x][y1], E[x][y2]) for y in range(y1, y2+1): co = min(co, E[x1][y], E[x2][y]) ci = 0 cnt = 0 for x in range(x1+1, x2): for y in range(y1+1, y2): ci = max(ci, E[x][y]) cnt += E[x][y] if ci < co: ans = max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt) print(ans)
s354104636
p01103
u148477094
1527046026
Python
Python3
py
Runtime Error
0
0
825
while 1: d, w = map(int, input().split()) if d==w==0: break E=[list(map(int, input().split())) for i in range(d)] a=0 for x2 in range(d): for y2 in range(w): for x1 in range(x2-1): for y1 in range(y2-1): co=10**18 for x in range(x1, x2+1): co=min(co, E[x][y1], E[x][y2]) for y in range(y1, y2+1): co=min(co, E[x1][y], E[x2][y]) ci=cnt=0 for x in range(x1+1, x2): for y in range(y1+1, y2): ci=max(ci, E[x][y]) cnt+=E[x][y] if ci < co: a=max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt) print(a)
s111247307
p01103
u148477094
1527046053
Python
Python3
py
Runtime Error
0
0
825
while 1: d, w = map(int, input().split()) if d==w==0: break E=[list(map(int, input().split())) for i in range(d)] a=0 for x2 in range(d): for y2 in range(w): for x1 in range(x2-1): for y1 in range(y2-1): co=10**18 for x in range(x1, x2+1): co=min(co, E[x][y1], E[x][y2]) for y in range(y1, y2+1): co=min(co, E[x1][y], E[x2][y]) ci=cnt=0 for x in range(x1+1, x2): for y in range(y1+1, y2): ci=max(ci, E[x][y]) cnt+=E[x][y] if ci < co: a=max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt) print(a)
s616764035
p01103
u148477094
1527046114
Python
Python3
py
Runtime Error
0
0
828
while True: d, w = map(int, input().split()) if d==w==0: break E=[list(map(int, input().split())) for i in range(d)] a=0 for x2 in range(d): for y2 in range(w): for x1 in range(x2-1): for y1 in range(y2-1): co=10**18 for x in range(x1, x2+1): co=min(co, E[x][y1], E[x][y2]) for y in range(y1, y2+1): co=min(co, E[x1][y], E[x2][y]) ci=cnt=0 for x in range(x1+1, x2): for y in range(y1+1, y2): ci=max(ci, E[x][y]) cnt+=E[x][y] if ci < co: a=max(ans, (x2-x1-1)*(y2-y1-1)*co - cnt) print(a)
s536396611
p01104
u260980560
1500998277
Python
Python3
py
Runtime Error
0
0
245
while 1: n, m = map(int, input().split()) if n+m == 0: break B = [int(input(),2) for i in range(n)] C = {0: 0} for b in B: for k, v in [*C.items()]: C[k^b] = max(C.get(k^b, 0), v+1) print(C[0])
s548409619
p01104
u260980560
1501208622
Python
Python3
py
Runtime Error
0
0
1082
a=65280; b=61680; c=52428; d=43690; e=65535 QS = [[] for i in range(17)] QS[1] = [a, b, c, d] L = {a: 1, b: 1, c: 1, d: 1, e: 1, e: 1, 0: 1} H = [] get = L.get push = H.append for l in range(1, 16): Q = QS[l] li = 13-l; l3 = l+3; l1 = l+1 pop = Q.pop pushQN = QS[l1].append while Q: p = pop() if L[p] < l: continue if l < 13: if l1 < get(p ^ e, 17): L[p ^ e] = l1 l < 12 and pushQN(p ^ e) for q, r in H: if r < li: if l3+r < get(p & q, 17): L[p & q] = l3+r; QS[l3+r].append(p & q) if l3+r < get(p ^ q, 17): L[p ^ q] = l3+r; QS[l3+r].append(p ^ q) elif r == li: if p & q not in L: L[p & q] = 16 if p ^ q not in L: L[p ^ q] = 16 else: break l < 7 and push((p, l)) elif l1 < get(p ^ e, 17): L[p ^ e] = l1 print(*map(L.__getitem__, eval("e&"+",e&".join(open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]))),sep='\n')
s397475554
p01104
u260980560
1501208875
Python
Python3
py
Runtime Error
0
0
1071
a=65280; b=61680; c=52428; d=43690; e=65535 QS = [[] for i in range(17)] QS[1] = [a, b, c, d] L = {a: 1, b: 1, c: 1, d: 1, e: 1, e: 1, 0: 1} H = [] get = L.get push = H.append for l in range(1, 16): Q = QS[l] li = 13-l; l3 = l+3; l1 = l+1 pop = Q.pop pushQN = QS[l1].append while Q: p = pop() if L[p] < l: continue if l < 13: if l1 < get(p ^ e, 17): L[p ^ e] = l1 pushQN(p ^ e) for q, r in H: if r < li: if l3+r < get(p & q, 17): L[p & q] = l3+r; QS[l3+r].append(p & q) if l3+r < get(p ^ q, 17): L[p ^ q] = l3+r; QS[l3+r].append(p ^ q) elif r == li: if p & q not in L: L[p & q] = 16 if p ^ q not in L: L[p ^ q] = 16 else: break l < 7 and push((p, l)) elif l1 < get(p ^ e, 17): L[p ^ e] = l1 print(*map(L.__getitem__, eval("e&"+",e&".join(open(0).read().replace(*"-~").replace(*"*&").replace(*"1e").split()[:-1]))),sep='\n')
s942430667
p01104
u196653484
1526548813
Python
Python3
py
Runtime Error
0
0
1221
import itertools def addlist(a,b,m): result=[0 for i in range(m)] for i in range(m): c=a[i]+b[i] result[i] = c%2 return result def sum(b): result=0 for i in b: result += i return result def make(b,m,n,l): sumlist=[] flag=False p=list(itertools.combinations(b,l)) for i in p: ls=[0 for i in range(m)] for j in list(i): ls=addlist(ls,j,m) sumlist.append(ls) for i in sumlist: s=sum(i) if s == 0: flag = True if flag: return l else: l-=1 if l<=0: return 0 else: return make(b,m,n,l) if __name__ == "__main__": boxes=[] while True: a=list(map(int,input().split())) n=a[0] m=a[1] if n == 0 and m == 0: break else: b=[] for i in range(n): num=[] tmp=int(input()) for j in range(m): num.append(tmp%10) tmp = tmp//10 num.reverse() b.append(num) boxes.append(make(b,m,n,n)) for i in boxes: print(i)
s573005395
p01104
u196653484
1526551437
Python
Python3
py
Runtime Error
0
0
1228
import itertools def addlist(a,b,m): result=[0 for i in range(m)] for i in range(m): c=a[i]+b[i] result[i] = c%2 return result def sum(b): result=0 for i in b: result += i return result def make(b,m,n,l): sumlist=[] flag=False p=list(itertools.combinations(b,l)) for i in p: ls=[0 for i in range(m)] for j in list(i): ls=addlist(ls,j,m) sumlist.append(ls) for i in sumlist: s=sum(i) if s == 0: flag = True if flag: return l else: l-=1 if l<=0: return 0 else: return make(b,m,n,l) if __name__ == "__main__": boxes=[] while True: a=list(map(int,input().split())) n=a[0] m=a[1] if n == 0 and m == 0: break else: b=[] for i in range(n): num=[] tmp=int(input()) for j in range(m): num.append(tmp%10) tmp = tmp//10 num.reverse() b.append(num) boxes.append(make(b,m,n,n)) for i in boxes: print(i)
s426270832
p01109
u258535552
1535947905
Python
Python3
py
Runtime Error
0
0
173
n=int(input()) a=[int(i) for i in input().split] total=0 for i in a: total+=i hei=total/n count=0 for i in a: if i <= hei: count+=1 print(count)
s636822771
p01110
u191474223
1559115811
Python
Python3
py
Runtime Error
0
0
2301
from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpl_str(): return list(input().split()) def rev_w(MAP,H,W): nextMAP = [[] for y in range(H)] for y in range(H): nextMAP[y] = MAP[y][::-1] return nextMAP def rev_h(MAP,H,W): nextMAP = [[] for y in range(H)] for y in range(H): for x in range(W): nextMAP[y][x] = MAP[H-y-1][x] return nextMAP while True: W,H,t,p = inpl() if W == 0: break else: MAP = [[1]*W for y in range(H)] for _ in range(t): d,c = inpl() if d == 1: if W//2 >= c: hanten = False else: hanten = True if hanten: MAP = rev_w(MAP,H,W) c = W - c nextW = W - c nextH = H nextMAP = [[1]*nextW for y in range(H)] for y in range(H): for x in range(c): nextMAP[y][x] = MAP[y][x+c] + MAP[y][(c-1)-x] for x in range(c,nextW): nextMAP[y][x] = MAP[y][x+c] if hanten: nextMAP = rev_w(nextMAP,H,nextW) elif d == 2: if H//2 >= c: hanten = False else: hanten = True if hanten: MAP = rev_h(MAP,H,W) c = H - c nextW = W nextH = H - c nextMAP = [[1]*W for y in range(nextH)] for x in range(W): for y in range(c): nextMAP[y][x] = MAP[y+c][x] + MAP[(c-1)-y][x] for y in range(c,nextH): nextMAP[y][x] = MAP[y+c][x] if hanten: nextMAP = rev_h(nextMAP,H,nextW) MAP = nextMAP[:] H,W = nextH,nextW #for m in nextMAP: # print(m) for _ in range(p): x,y = inpl() print(MAP[y][x])
s482095810
p01110
u046108504
1559498887
Python
Python3
py
Runtime Error
0
0
1495
from operator import add def fold_right(v, length): for i in range(len(v[0])): if not any(list(zip(*v))[i]): continue for j in range(length): for yoko in range(len(v)): v[yoko][i + j + length] += v[yoko][i + j] v[yoko][i + j] = 0 return v def fold_up(v, length): for i in range(len(v) - 1, -1, -1): if not any(v[i]): continue for j in range(length): v[i - j - length] = list(map(add, v[i - j - length], v[i - j])) v[i - j] = [0] * len(v[i - j]) return v def cut_cut_cut(v, x, y): for i in range(len(v) - 1, -1, -1): if not any(v[i]): continue y = i - y break for i in range(len(v[0])): if not any(list(zip(*v))[i]): continue x = i + x break return v[y][x] while True: n, m, t, p = map(int, input().split()) if n == 0 and m == 0 and t == 0 and p == 0: break origami = [[0] * 63 for _ in range(63)] for i in range(m): for j in range(n): origami[len(origami) - 1 - i][j] = 1 for i in range(t): d, c = map(int, input().split()) if d == 1: origami = fold_right(origami, c) else: origami = fold_up(origami, c) # print(*origami, sep="\n") # print() for i in range(p): x, y = map(int, input().split()) print(cut_cut_cut(origami, x, y))
s052355599
p01111
u300645821
1531405748
Python
Python
py
Runtime Error
0
0
237
import sys while True: n=int(sys.stdin.readline()) if not n: break head=tail=1 s=0 while True: while s<N: s+=tail tail+=1 while s>N: s-=head head+=1 if s==N sys.stdout.write('%d %d\n'%(head,tail-head)) break
s744910808
p01111
u300645821
1531405805
Python
Python
py
Runtime Error
0
0
238
import sys while True: n=int(sys.stdin.readline()) if not n: break head=tail=1 s=0 while True: while s<n: s+=tail tail+=1 while s>n: s-=head head+=1 if s==n: sys.stdout.write('%d %d\n'%(head,tail-head)) break
s285414644
p01111
u300645821
1531405812
Python
Python3
py
Runtime Error
0
0
238
import sys while True: n=int(sys.stdin.readline()) if not n: break head=tail=1 s=0 while True: while s<n: s+=tail tail+=1 while s>n: s-=head head+=1 if s==n: sys.stdout.write('%d %d\n'%(head,tail-head)) break
s747707321
p01125
u296492699
1409860815
Python
Python
py
Runtime Error
0
0
2064
while True: &#160;&#160;&#160;&#160;num_hoseki=input() &#160;&#160;&#160;&#160;if num_hoseki==0: &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;hoseki_list=[] &#160;&#160;&#160;&#160;for i in range(num_hoseki): &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;hoseki_list.append(map(int,raw_input().split())) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;num_meirei=input() &#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;keiro=[] &#160;&#160;&#160;&#160;x,y=[10,10] &#160;&#160;&#160;&#160;for i in range(num_meirei): &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;meirei=raw_input() &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;d, l=meirei.split() &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;l=int(l) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if d=='N': &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dx,dy=0,1 &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;elif d=='S': &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dx,dy=0,-1 &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;elif d=='W': &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dx,dy=-1,0 &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;elif d=='E': &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;dx,dy=1,0 &#160; &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;for j in range(l): &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;keiro.append([x+(j+1)*dx,y+(j+1)*dy]) &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;x,y=keiro[-1] &#160;&#160;&#160;&#160;flag=True &#160;&#160;&#160;&#160;for hoseki in hoseki_list: &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if not hoseki in keiro: &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;flag=False &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;break if flag: print 'Yes' else: print 'No'
s953910683
p01125
u266872031
1422111822
Python
Python
py
Runtime Error
0
0
1396
while(1): N=int(raw_input()) if N==0: break else: gems=[] okflag=0 loc=[10,10] for i in range(N): [gemx,gemy]=[int(x) for x in raw_input().split()] gems.append([gemx,gemy]) M=int(raw_input()) for i in range(M): com=raw_input().split() com[1]=int(com[1]) if com[0]=="N": for j in range(com[1]): loc[1]=loc[1]+1 if loc in gems: gems.remove(loc) #loc[1]=loc[1]+com[1] elif com[0]=="S": for j in range(com[1]): loc[1]=loc[1]-1 if loc in gems: gems.remove(loc) #loc[1]=loc[1]-com[1] elif com[0]=="E": for j in range(com[1]): loc[0]=loc[0]+1 if loc in gems: gems.remove(loc) #loc[0]=loc[0]+com[1] else: for j in range(com[1]): loc[0]=loc[0]-1 if loc in gems: gems.remove(loc) #loc[0]=loc[0]-com[1] if len(gems)==0: okflag=1 break if okflag: print "Yes" else: print "No"
s876620110
p01125
u078042885
1485629061
Python
Python3
py
Runtime Error
0
0
393
while 1: n=int(input()) if n==0:break x=y=10 b=[list(map(int,input().split())) for _ in range(n)] print(b) for i,j in [input().split() for _ in range(int(input()))]: for _ in range(int(j)): if 'N'<=i<='S': y+=1 if i=='N' else -1 else: x+=1 if i=='E' else -1 if [x,y] in b:del b[b.index([x,y])] print(['Yes','No'][len(b)])
s778957062
p01125
u078042885
1485629115
Python
Python3
py
Runtime Error
0
0
380
while 1: n=int(input()) if n==0:break x=y=10 b=[list(map(int,input().split())) for _ in range(n)] for i,j in [input().split() for _ in range(int(input()))]: for _ in range(int(j)): if 'N'<=i<='S': y+=1 if i=='N' else -1 else: x+=1 if i=='E' else -1 if [x,y] in b:del b[b.index([x,y])] print(['Yes','No'][len(b)])
s794468418
p01125
u974788383
1506842707
Python
Python3
py
Runtime Error
0
0
1616
while (True): pos = [10, 10] result = 'No' N = int(input()) # Total number of jewels if N == 0: break jewelPositions = list() for i in range(N): jewelPos = list(map(int, input().split())) jewelPositions.append(jewelPos) M = int(input()) # Number of instructions # instructions = list() for i in range(M): # print('==== Currently at ', pos) instruction = input().split() instruction[1] = int(instruction[1]) if (instruction[0] == 'E'): move = ('x', instruction[1]) elif (instruction[0] == 'W'): move = ('x', -1*instruction[1]) elif (instruction[0] == 'N'): move = ('y', instruction[1]) elif (instruction[0] == 'S'): move = ('y', -1*instruction[1]) else: raise NotImplementedError for jewel in jewelPositions: if ((move[0] == 'x') and (pos[1] == jewel[1]) and (pos[0] <= jewel[0] <= pos[0]+move[1])) \ or ((move[0] == 'y') and (pos[0] == jewel[0]) and (pos[1] <= jewel[1] <= pos[1]+move[1])): # print('---- Collecting a jewel at ', jewel) jewelPositions.remove(jewel) if (move[0] == 'x'): pos[0] += move[1] elif (move[0] == 'y'): pos[1] += move[1] if not jewelPositions: """ if empty, all jewels are collected """ result = 'Yes' break else: pass # print('jewels are left at ', jewelPositions) print(result)
s677868049
p01125
u256256172
1506944011
Python
Python3
py
Runtime Error
0
0
557
while True: n = int(input()) if n == 0: break p = [10, 10] l = [list(map(int,input().split())) for _ in range(n)] for d,s in [input.split() for _ in range(int(input()))]: for _ in range(s): if d == 'N': p[1] += 1 elif d == 'E': p[0] += 1 elif d == 'W': p[0] -= 1 elif d == 'S': p[1] -= 1 if p in l: l.remove(p) if len(l) == 0: print('Yes') else: print('No')
s221551461
p01125
u256256172
1506993659
Python
Python
py
Runtime Error
0
0
559
while True: n = int(input()) if n == 0: break p = [10, 10] l = [list(map(int,input().split())) for _ in range(n)] for d,s in [input().split() for _ in range(int(input()))]: for _ in range(s): if d == 'N': p[1] += 1 elif d == 'E': p[0] += 1 elif d == 'W': p[0] -= 1 elif d == 'S': p[1] -= 1 if p in l: l.remove(p) if len(l) == 0: print('Yes') else: print('No')
s571083966
p01126
u978831775
1415114875
Python
Python
py
Runtime Error
0
0
631
# coding: utf-8 def main(): while True: (n, m, a) = map(int, raw_input().split(' ')) if (n, m, a) == (0, 0, 0): break bars = [] for i in range(m): (h, p, q) = map(int, raw_input().split(' ')) bars.append((h, p, q)) x = a while True: # Down step by step, and above bars are removed in each step next_bar = max([b for b in bars if b[1] == x or b[2] == x]) x = next_bar[2] if next_bar[1] == x else next_bar[1] y = next_bar[0] map(lambda b: bars.remove(b), [b for b in bars if b[0] >= y]) if bars == []: break print x if __name__ == '__main__': main()
s527848793
p01126
u617183767
1420615649
Python
Python
py
Runtime Error
0
0
891
#! /usr/bin/env python # -*- coding: utf-8 -*- import os import sys import itertools import math from collections import Counter, defaultdict class Main(object): def __init__(self): pass def solve(self): ''' insert your code ''' while True: n, m, a = map(int, raw_input().split()) if n == 0 and m == 0 and a == 0: break adj = [[] for i in range(m)] for i in range(m): h, p, q = map(int, raw_input().split()) adj[h].append((p, q)) for e in reversed(adj): for p, q in e: if p == a: a = q elif q == a: a = p print a return None if __name__ == '__main__': m = Main() m.solve()
s774089363
p01126
u124909914
1426643028
Python
Python3
py
Runtime Error
0
0
374
while True: n, m, a = map(int, input().split()) if n == 0: break ls = [[0 for i in range(n+1)] for i in range(m)] print(ls) for i in range(m): h, p, q = map(int, input().split()) ls[h][p] = 1 ls.reverse() print(ls) for t in ls: if t[a] == 1: a += 1 elif t[a-1] == 1: a -= 1 print(a)
s309866426
p01126
u248416507
1464101487
Python
Python
py
Runtime Error
0
0
588
if __name__ == "__main__": while True: n, m, a = map(int, raw_input().split()) if n == 0 and m == 0 and a == 0: break now = a amida = [[] for i in range(1000)] for i in range(m): h, p, q = map(int, raw_input().split()) amida[h].append((p, q)) for height in range(1000 - 1, 0, -1): lines = amida[height] for l in lines: if l[0] == now: now = l[1] elif l[1] == now: now = l[0] print now
s794952288
p01126
u248416507
1464101507
Python
Python
py
Runtime Error
0
0
588
if __name__ == "__main__": while True: n, m, a = map(int, raw_input().split()) if n == 0 and m == 0 and a == 0: break now = a amida = [[] for i in range(1000)] for i in range(m): h, p, q = map(int, raw_input().split()) amida[h].append((p, q)) for height in range(1000 - 1, 0, -1): lines = amida[height] for l in lines: if l[0] == now: now = l[1] elif l[1] == now: now = l[0] print now
s329578307
p01126
u858885710
1466502965
Python
Python3
py
Runtime Error
0
0
416
while True: n, m, a = map(int, input().split()) if n + m + a == 0: break lines = list(reversed(sorted([tuple(map(int, input().split())) for _ in range(m)]))) replace = list(range(1, n+1)) for l in lines: h, p, q = l p -= 1 q -= 1 replace[p], replace[q] = replace[q], replace[p] a -= 1 for _ in range(n): a = replace[a] print(a)
s726860097
p01126
u616098312
1466503847
Python
Python3
py
Runtime Error
0
0
315
while True: [n,m,a]=input().split() if [n,m,a]==["0","0","0"]: break [n,m,a]=[int(n),int(m),int(a)] yokobo={} for k in range(m): [h,p,q]=input().sprit() yokobo[h,p]=[int(q)] yokobo[h,q]=[int(p)] move=1000 while move>0: a=yokobo[move,a] move=move-1
s799009082
p01126
u685815919
1474601047
Python
Python
py
Runtime Error
0
0
401
while True: n,m,a = map(int, raw_input().split()) if n==m==a==0: break lst = [0] * n for i in xrange(n): lst[i] = i ms = {} for _ in xrange(n): h,p,q = map(int, raw_input().split()) if h not in ms: ms[h] = {} ms[h][p] = q for i,v in sorted(ms.items()): for k,l in v.items(): tmp = lst[k-1] lst[k-1] = lst[l-1] lst[l-1] = tmp print lst[a-1]+1
s288674450
p01126
u936898312
1492606793
Python
Python3
py
Runtime Error
0
0
431
while True: n, m, a = map(int, input().split()) if (not (n or m or a)): break amida = [[] for i in range(n)] for i in range(n): h, p, q = map(int, input().split()) amida[p-1].append((h, q-1)) amida[q-1].append((h, p-1)) for i in range(n): amida[i].sort() a -= 1 h = 1000 while amida[a]: h2, a2 = amida[a].pop() while h2 >= h and amida[a]: h2, a2 = amida[a].pop() if h2 < h: h, a = (h2, a2) print(a+1)
s704528767
p01126
u179694829
1498973057
Python
Python3
py
Runtime Error
0
0
300
while True: n,m,a = map(int,input().split()) if n == m == a == 0: break A = [[0]*1002 for i in range(n + 1)] for i in range(m + 1): h,p,q = map(int,input().split()) A[p][1001 - h] = q A[q][1001 - h] = p for i in range(1001): if A[a][i] == 0: pass else: a = A[a][i] print(a)
s196941371
p01126
u506554532
1513127999
Python
Python3
py
Runtime Error
0
0
258
N,M,A = map(int,input().split()) amd = [{} for i in range(1001)] for i in range(M): h,p,q = map(int,input().split()) amd[h][p] = q amd[h][q] = p raw_input() #ignore now = A for d in reversed(amd): if now in d: now = d[now] print(now)
s384676741
p01126
u591052358
1528895821
Python
Python3
py
Runtime Error
0
0
698
N = 10**6 N1 = [i for i in range(N+40)] N2 = [i for i in range(N+40)] #N1[0] = 0 #N2[0] = 0 p = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1] p2 = [n*(n+1)*(n+2)//6 for n in range(1,200) if n *(n+1)*(n+2)//6< N+1 and n *(n+1)*(n+2)//6 % 2 ==1 ] #print(p2) for p_ in p: if p_ > N +1: continue n = min(p_*5,10**6) for j in range(p_,n): # print(j) if N1[j] > N1[j-p_] +1: N1[j] = N1[j-p_]+1 for p_ in p2: if p_ > N +1 : continue for j in range(p_,N +1): if N2[j] > N2[j-p_]+1: N2[j] = N2[j -p_]+1 print('a') while True: n = int(input()) if n == 0: break print(N1[n],N2[n])
s355706810
p01126
u459861655
1350625214
Python
Python
py
Runtime Error
0
1004
669
n, m, a = [int(x) for x in raw_input().strip().split()] lines = [] while True: h, p, q = [int(x) for x in raw_input().strip().split()] if h == p == q == 0: break else: lines.append([h, p, q]) verticals = [[] for i in xrange(n)] for i in xrange(n): for l in lines: if l[1] == i + 1 or l[2] == i + 1: verticals[i].append(l) t = sorted(verticals[i], reverse = True) verticals[i] = t def solve(height, pos): for line in verticals[pos - 1]: if line[0] < height: height = line[0] if line[1] == pos: pos = line[2] else: pos = line[1] return solve(height, pos) print pos return solve(10000, a)
s869825722
p01126
u351182591
1375714266
Python
Python
py
Runtime Error
20000
4268
660
while 1: num=map(int,raw_input().split()) if num==[0,0,0] : break hrz=[0 for i in range(num[1])] for i in range(num[1]): hrz[i]=map(int,raw_input().split()) lct=[1001,num[2]] while lct[0]!=1: pps=[0,0] for i in range(num[1]): if pps[0]<hrz[i][0]<lct[0]: if hrz[i][1]==lct[1]: pps=[hrz[i][0],hrz[i][2]] elif hrz[i][2]==lct[1]: pps=[hrz[i][0],hrz[i][1]] lct=pps print lct[1]
s239074154
p01127
u633068244
1428311159
Python
Python
py
Runtime Error
19930
4776
1133
from itertools import permutations from collections import defaultdict import copy def judge(field, c): for y in xrange(corner[c][2], corner[c][3] + 1): for x in xrange(corner[c][0], corner[c][1] + 1): if field[y][x] != c and field[y][x] != "*": return False field[y][x] = "*" return True N = int(raw_input()) for loop in xrange(N): h, w = map(int, raw_input().split()) field = [list(raw_input()) for i in xrange(h)] chars = set([]) corner = defaultdict(lambda :[101,-1,101,-1]) for y in xrange(h): for x in xrange(w): c = field[y][x] if c == ".": continue chars.add(c) corner[c][0] = min(corner[c][0], x) corner[c][1] = max(corner[c][1], x) corner[c][2] = min(corner[c][2], y) corner[c][3] = max(corner[c][3], y) for order in permutations(chars): cp = copy.deepcopy(field) for c in order: if not judge(cp, c): break else: print "SAFE" break else: print "SUSPICIOUS"
s508083553
p01127
u633068244
1428311371
Python
Python
py
Runtime Error
19930
4772
1129
from itertools import permutations from collections import defaultdict import copy def judge(field, c): for y in xrange(corner[c][2], corner[c][3] + 1): for x in xrange(corner[c][0], corner[c][1] + 1): if field[y][x] != c and field[y][x] != "*": return False field[y][x] = "*" return True N = int(raw_input()) for loop in xrange(N): h, w = map(int, raw_input().split()) field = [list(raw_input()) for i in xrange(h)] chars = set([]) corner = defaultdict(lambda :[49,0,49,0]) for y in xrange(h): for x in xrange(w): c = field[y][x] if c == ".": continue chars.add(c) corner[c][0] = min(corner[c][0], x) corner[c][1] = max(corner[c][1], x) corner[c][2] = min(corner[c][2], y) corner[c][3] = max(corner[c][3], y) for order in permutations(chars): cp = copy.deepcopy(field) for c in order: if not judge(cp, c): break else: print "SAFE" break else: print "SUSPICIOUS"
s232894524
p01127
u633068244
1428311630
Python
Python
py
Runtime Error
19930
4676
1107
from itertools import permutations from collections import defaultdict def judge(field, c): for y in xrange(corner[c][2], corner[c][3] + 1): for x in xrange(corner[c][0], corner[c][1] + 1): if field[y][x] != c and field[y][x] != "*": return False field[y][x] = "*" return True N = int(raw_input()) for loop in xrange(N): h, w = map(int, raw_input().split()) field = [raw_input() for i in xrange(h)] chars = set([]) corner = defaultdict(lambda :[49,0,49,0]) for y in xrange(h): for x in xrange(w): c = field[y][x] if c == ".": continue chars.add(c) corner[c][0] = min(corner[c][0], x) corner[c][1] = max(corner[c][1], x) corner[c][2] = min(corner[c][2], y) corner[c][3] = max(corner[c][3], y) for order in permutations(chars): cp = map(list, field) for c in order: if not judge(cp, c): break else: print "SAFE" break else: print "SUSPICIOUS"
s061071485
p01127
u633068244
1428311662
Python
Python3
py
Runtime Error
0
0
1109
from itertools import permutations from collections import defaultdict def judge(field, c): for y in xrange(corner[c][2], corner[c][3] + 1): for x in xrange(corner[c][0], corner[c][1] + 1): if field[y][x] != c and field[y][x] != "*": return False field[y][x] = "*" return True N = int(raw_input()) for loop in xrange(N): h, w = map(int, raw_input().split()) field = [raw_input() for i in xrange(h)] chars = set([]) corner = defaultdict(lambda :[49,0,49,0]) for y in xrange(h): for x in xrange(w): c = field[y][x] if c == ".": continue chars.add(c) corner[c][0] = min(corner[c][0], x) corner[c][1] = max(corner[c][1], x) corner[c][2] = min(corner[c][2], y) corner[c][3] = max(corner[c][3], y) for order in permutations(chars): cp = map(list, field) for c in order: if not judge(cp, c): break else: print("SAFE") break else: print("SUSPICIOUS")
s785718782
p01127
u260980560
1467371765
Python
Python
py
Runtime Error
40000
6372
1475
from itertools import permutations for t in xrange(input()): h, w = map(int, raw_input().split()) A = [list(raw_input()) for i in xrange(h)] xmin = {}; xmax = {} ymin = {}; ymax = {} obj = set() for i in xrange(h): for j in xrange(w): c = A[i][j] if c == '.': continue xmin[c] = min(xmin.get(c, 99), j) xmax[c] = max(xmax.get(c, -1), j) ymin[c] = min(ymin.get(c, 99), i) ymax[c] = max(ymax.get(c, -1), i) obj.add(c) if not obj: print "SAFE" continue ok = 1 for q in obj: for i in xrange(ymin[q], ymax[q]+1): for j in xrange(xmin[q], xmax[q]+1): if A[i][j] == '.': ok = 0 break if not ok: break if not ok: break if not ok: print "SUSPICIOUS" continue for p in permutations(obj): valid = [[1]*w for i in xrange(h)] ok = 1 for q in p: for i in xrange(ymin[q], ymax[q]+1): for j in xrange(xmin[q], xmax[q]+1): if A[i][j] != q and not valid[i][j]: ok = 0 break elif A[i][j] == q: valid[i][j] = 0 if not ok: break if not ok: break if ok: print "SAFE" break else: print "SUSPICIOUS"
s773501899
p01128
u509278866
1530781155
Python
Python3
py
Runtime Error
0
0
1801
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools sys.setrecursionlimit(10**7) inf = 10**20 eps = 1.0 / 10**10 mod = 10**9+7 dd = [(-1,0),(0,1),(1,0),(0,-1)] ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)] def LI(): return [int(x) for x in sys.stdin.readline().split()] def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()] def LF(): return [float(x) for x in sys.stdin.readline().split()] def LS(): return sys.stdin.readline().split() def I(): return int(sys.stdin.readline()) def F(): return float(sys.stdin.readline()) def S(): return input() def pf(s): return print(s, flush=True) def intersection(a1, a2, b1, b2): x1,y1 = a1 x2,y2 = a2 x3,y3 = b1 x4,y4 = b2 ksi = (y4 - y3) * (x4 - x1) - (x4 - x3) * (y4 - y1) eta = (x2 - x1) * (y4 - y1) - (y2 - y1) * (x4 - x1) delta = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) ramda = ksi / delta; mu = eta / delta; if ramda >= 0 and ramda <= 1 and mu >= 0 and mu <= 1: return (x1 + ramda * (x2 - x1), y1 + ramda * (y2 - y1)) return None def main(): rr = [] n = I() ni = 0 while ni < n: ni += 1 xa,ya,xb,yb = LI() a1 = (xa,ya) a2 = (xb,yb) m = I() a = [LI() for _ in range(m)] t = [] for xs,ys,xt,yt,o,l in a: k = intersection(a1,a2,(xs,ys),(xt,yt)) if k is None: continue t.append((k,o^l)) if len(t) == 0: rr.append(0) continue t.sort() c = t[0][1] r = 0 for _,tc in t: if tc != c: r += 1 c = tc rr.append(r) return '\n'.join(map(str, rr)) print(main())
s283923947
p01128
u598551137
1514336049
Python
Python3
py
Runtime Error
0
0
890
for i in range(int(input())): xa, ya, xb, yb = map(int, input().split(' ')) n = int(input()) ip = [] for j in range(n): xs, ys, xt, yt, o, l = map(int, input().split(' ')) d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs) if d == 0: continue t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d if t0 < 0 or t0 > 1 or t1 < 0 or t1 > 1: continue ip.append((t0, o, l)) ip.sort(key=lambda x: x[0]) count = 0 if len(ip) > 0: l = ip[0][2] if ip[0][1] == 1 else abs(ip[0][2] - 1) for p in ip[1:]: if p[1] == 0 and l == p[2]: l = abs(l - 1) count += 1 elif p[1] == 1 and l != p[2]: l = abs(l - 1) count += 1 print(count)
s849525163
p01128
u598551137
1514370996
Python
Python3
py
Runtime Error
0
0
691
for i in range(int(input())): xa, ya, xb, yb = map(int, input().split(' ')) n = int(input()) ip = [] for j in range(n): xs, ys, xt, yt, o, l = map(int, input().split(' ')) d = (xb - xa) * (yt - ys) - (yb - ya) * (xt - xs) continue t0 = ((yt - ys) * (xs - xa) - (xt - xs) * (ys - ya)) / d t1 = ((yb - ya) * (xs - xa) - (xb - xa) * (ys - ya)) / d if (t0 >= 0 and t0 <= 1) and (t1 >= 0 and t1 <= 1): ip.append((t0, o == l)) count = 0 if len(ip) > 0 ip.sort(key=lambda x: x[0]) for j in range(len(ip) - 1): if ip[i][1] != ip[i + 1][1]: count += 1 print(count)