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
s087358633
p03880
u382423941
1480365526
Python
Python (3.4.3)
py
Runtime Error
698
9672
464
import math as m import functools def int_reverse(num): num_len = len(bin(num))-2 f = 2**num_len-1 return num ^ f n = int(input()) A = [int(input()) for i in range(n)] lsbs = [[i for i in range(int(m.log2(a))+1) if (a>>i)&1][0] for a in A] nim = functools.reduce(lambda x,y:x^y, A) cnt = 0 for lsb in reversed(sorted(lsbs)): if int(m.log2(nim)) == lsb: nim = int_reverse(nim) cnt += 1 ans = cnt if(nim == 0) else -1 print(ans)
s701905081
p03881
u335979702
1480365183
Python
Python (2.7.6)
py
Runtime Error
17
2696
439
a = [int(i) for i in raw_input().split()] b = [int(i) for i in raw_input().split()] n = len(a) c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i]+1e-10)) for i in range(n)] c.sort(key=lambda item: item[3], reverse=True) u = [0] * n res = 1 for i in range(n): du = min(res / (c[i][2]), 1) u[i] = du res -= du * c[i][2] if res <=0: break ans = 0 for i in range(n): ans += c[i][0] * u[i] print ans
s904346995
p03881
u335979702
1480365072
Python
Python (2.7.6)
py
Runtime Error
17
2696
433
a = [int(i) for i in raw_input().split()] b = [int(i) for i in raw_input().split()] n = len(a) c = [(a[i]/100.0,b[i]/100.0,(a[i]+b[i])/100.0,a[i]*1.0/(a[i]+b[i])) for i in range(n)] c.sort(key=lambda item: item[3], reverse=True) u = [0] * n res = 1 for i in range(n): du = min(res / (c[i][2]), 1) u[i] = du res -= du * c[i][2] if res <=0: break ans = 0 for i in range(n): ans += c[i][0] * u[i] print ans
s518238594
p03883
u102461423
1569689356
Python
Python (3.4.3)
py
Runtime Error
1828
23180
1706
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines import numpy as np N = int(readline()) LR = [tuple(int(x) for x in line.split()) for line in readlines()] """ ・奇数個のとき:中央にどれかを固定。 ・偶数のとき:原点で左右に分けるとしてよい。 ・基本的に長さで内側から昇順(奇数のときの中央は謎)。→ソートしてdpできる。 ・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。 ・偶数のときは、中央に1つ置いた状態から始める。 ・大きい区間から外側に入れていく。 """ LR.sort(key = lambda x: -x[1]-x[0]) if N%2 == 1: raise Exception INF = 10**18 dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。 dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。 if N&1: dp_0[0] = 0 else: dp_1[0] = 0 for n,(L,R) in enumerate(LR): length = R + L prev_0 = dp_0 prev_1 = dp_1 dp_0 = np.full(N+1,INF,np.int64) dp_1 = np.full(N+1,INF,np.int64) x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数 # 左側に置く場合 np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2]) np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2]) # 右側に置く場合 np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1]) np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1]) # 中央に置く場合 np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1]) answer = dp_1[N//2] print(answer)
s028767864
p03883
u102461423
1569689209
Python
Python (3.4.3)
py
Runtime Error
1714
22672
1704
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines import numpy as np N = int(readline()) LR = [tuple(int(x) for x in line.split()) for line in readlines()] """ ・奇数個のとき:中央にどれかを固定。 ・偶数のとき:原点で左右に分けるとしてよい。 ・基本的に長さで内側から昇順(奇数のときの中央は謎)。→ソートしてdpできる。 ・左に置いた個数をもってdp更新。また、中央を使ったかも同時に持って。 ・偶数のときは、中央に1つ置いた状態から始める。 ・大きい区間から外側に入れていく。 """ LR.sort(key = lambda x: -x[1]-x[0]) if N%2 == 1: raise Exception INF = 10**15 dp_0 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央未確定。 dp_1 = np.full(N+1,INF,np.int64) # 左に置いた個数 → コスト。中央確定。 if N&1: dp_0[0] = 0 else: dp_1[0] = 0 for n,(L,R) in enumerate(LR): length = R + L prev_0 = dp_0 prev_1 = dp_1 dp_0 = np.full(N+1,INF,np.int64) dp_1 = np.full(N+1,INF,np.int64) x = np.arange(n+1,dtype=np.int64) # もともと左側にあった個数 # 左側に置く場合 np.minimum(prev_0[:n+1] + R + x * length, dp_0[1:n+2], out=dp_0[1:n+2]) np.minimum(prev_1[:n+1] + R + x * length, dp_1[1:n+2], out=dp_1[1:n+2]) # 右側に置く場合 np.minimum(prev_0[:n+1] + L + (n-x) * length, dp_0[:n+1], out=dp_0[:n+1]) np.minimum(prev_1[:n+1] + L + (n-x) * length, dp_1[:n+1], out=dp_1[:n+1]) # 中央に置く場合 np.minimum(prev_0[:n+1] + (N-1)//2 * length, dp_1[:n+1], out = dp_1[:n+1]) answer = dp_1[N//2] print(answer)
s880906366
p03886
u102461423
1570499039
Python
Python (3.4.3)
py
Runtime Error
54
3812
2177
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools from heapq import heappop, heapify N,*A = map(int,read().split()) n90 = sum(x == 90 for x in A) if n90 - (N-n90) != 4: print(-1) exit() x = 0 temp = list(itertools.accumulate(1 if x == 90 else -1 for x in A)) slide = temp.index(min(temp)) + 1 A = A[slide:] + A[:slide] def F(left_node, right_node, R, depth): step = 1<<depth # L:左に曲がるインデックス集合 # R:右に曲がるインデックスのヒープ if not R: n1,n2,n3,n4 = [i for i,x in enumerate(left_node) if x is not None] X = [None] * N Y = [None] * N X[n1] = step; Y[n1] = 0 X[n2] = step; Y[n2] = step X[n3] = 0; Y[n3] = step X[n4] = 0; Y[n4] = 0 return X,Y r = heappop(R); l = left_node[r] # l番:90度、r番:270度 を消し飛ばす ll = left_node[l]; rr = right_node[r] left_node[rr] = ll; right_node[ll] = rr left_node[l] = None; left_node[r] = None right_node[l] = None; right_node[r] = None X,Y = F(left_node,right_node,R,depth+1) # 90,270を追加する dx = X[rr] - X[ll]; dy = Y[rr] - Y[ll] if dx > 0: Y[rr] += step X[l] = X[rr] - step; Y[l] = Y[ll] X[r] = X[l]; Y[r] = Y[rr] elif dx < 0: Y[rr] -= step X[l] = X[rr] + step; Y[l] = Y[ll] X[r] = X[l]; Y[r] = Y[rr] elif dy > 0: X[rr] -= step X[l] = X[ll]; Y[l] = Y[rr] - step X[r] = X[rr]; Y[r] = Y[l] elif dy < 0: X[rr] += step X[l] = X[ll]; Y[l] = Y[rr] + step X[r] = X[rr]; Y[r] = Y[l] return X,Y R = [i for i,x in enumerate(A) if x == 270] heapify(R) X,Y = F(list(range(-1,N-1)),list(range(1,N+1)),R,0) # 最初にずらしていた分 X = X[N-slide:] + X[:N-slide] Y = Y[N-slide:] + Y[:N-slide] # 最後に座圧して完成 x_to_i = {x:i for i,x in enumerate(sorted(set(X)))} y_to_i = {y:i for i,y in enumerate(sorted(set(Y)))} X = [x_to_i[x] for x in X] Y = [y_to_i[y] for y in Y] print('\n'.join('{} {}'.format(x,y) for x,y in zip(X,Y)))
s697213646
p03887
u102461423
1569037158
Python
Python (3.4.3)
py
Runtime Error
293
17540
1346
import sys readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 7) """ ・2,3^n,2 ・3(1) ・1 ・333 """ import numpy as np MOD = 10**9 + 7 N,A,B,C = map(int,readline().split()) if B&1: print(0) exit() def cumprod(arr): L = len(arr); Lsq = int(L**.5+1) arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq) for n in range(1,Lsq): arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD for n in range(1,Lsq): arr[n] *= arr[n-1,-1]; arr[n] %= MOD return arr.ravel()[:L] U = 10**5 x = np.arange(U,dtype=np.int64); x[0] = 1 fact = cumprod(x) x = np.arange(U,0,-1,dtype=np.int64); x[0] = pow(int(fact[-1]),MOD-2,MOD) fact_inv = cumprod(x)[::-1] """ ・2,3^n,2:B2個 ・3113:A-n個 ・11:n個 ・333333:m個 """ B2 = B//2 answer = 0 for m in range(C//3+1): n_min = max(0,A-C+3*m) # (B2+A+m)! / (B2)!(A-n)!(n)!(m)! x = fact[B2+A+m] * fact_inv[m] % MOD * fact_inv[B2] % MOD x *= fact_inv[A-n_min::-1]; x %= MOD x *= fact_inv[n_min:A+1]; x %= MOD # 2,3^n,2のところの3の振り分けを決める。B2個の非負整数の和がC-3m-(A-n) # (B2+A+m)! / (B2)!(A-n)!(n)!(m)! y = fact[B2-1+C-3*m-A+n_min:B2+C-3*m] * fact_inv[B2-1] % MOD y *= fact_inv[C-3*m-A+n_min:C-3*m+1]; y %= MOD answer += (x*y%MOD).sum() answer %= MOD print(answer)
s999609503
p03888
u104048422
1577151964
Python
Python (3.4.3)
py
Runtime Error
17
2940
45
a,b=map(int,input()) print((a**-1+b**-1)**-1)
s326290675
p03888
u807772568
1562102479
Python
Python (3.4.3)
py
Runtime Error
18
2940
46
n,m = map(input().split()) print((n*m)/(n+m))
s133820511
p03888
u171350173
1560576533
Python
Python (3.4.3)
py
Runtime Error
17
2940
40
print(1/(1/int(input())+1/int(input())))
s408283715
p03888
u326954876
1546448766
Python
Python (3.4.3)
py
Runtime Error
19
3060
60
r1 = (int)(input()) r2 = (int)(input()) print(r1*r2/(r1+r2))
s684233987
p03888
u233602244
1480458267
Python
Python (3.4.3)
py
Runtime Error
23
3064
61
a, b, c = map(int, input().split()) print((a * b / (a + b)))
s390424922
p03889
u426964396
1563899376
Python
Python (2.7.6)
py
Runtime Error
10
2568
476
#include<bits/stdc++.h> using namespace std; char s1[100100], s2[100100]; int leng; int main() { cin >> s1; for(int i = strlen(s1) - 1; i >= 0; i--) s2[leng++] = s1[i]; for(int i = 0; i < leng; i++) { if(s2[i]=='b') s2[i] = 'd'; else if (s2[i] == 'd') s2[i] = 'b'; else if (s2[i] == 'p') s2[i] = 'q'; else if (s2[i] == 'q') s2[i] = 'p'; } if(strcmp(s1, s2) == 0) puts("Yes"); else puts("No"); return 0; }
s251002578
p03889
u723721005
1563899171
Python
Python (2.7.6)
py
Runtime Error
10
2568
456
#include<bits/stdc++.h> using namespace std; string s1, s2; int leng; int main() { cin >> s1; for(int i = s1.size() - 1; i >= 0; i--) s2[leng++] = s1[i]; for(int i = 0; i < leng; i++) { if(s1[i]=='b') s2[i] = 'd'; else if (s1[i] == 'd') s2[i] = 'b'; else if (s1[i] == 'p') s2[i] = 'q'; else if (s1[i] == 'q') s2[i] = 'p'; } if(!strcmp(s1,s2)) puts("Yes"); else puts("No"); return 0; }
s135340385
p03889
u263933075
1563898973
Python
Python (2.7.6)
py
Runtime Error
12
2692
456
#include<bits/stdc++.h> using namespace std; strint s1, s2; int leng; int main() { cin >> s1; for(int i = s1.size() - 1; i >= 0; i--) s2[leng++] = s1[i]; for(int i = 0; i < leng; i++) { if(s1[i]=='b') s2[i] = 'd'; else if (s1[i] == 'd') s2[i] = 'b'; else if (s1[i] == 'p') s2[i] = 'q'; else if (s1[i] == 'q') s2[i] = 'p'; } if(!strcmp(s1,s2)) puts("Yes"); else puts("No"); return 0; }
s205872430
p03889
u476418095
1563898916
Python
Python (2.7.6)
py
Runtime Error
10
2568
453
#include<bits/stdc++.h> using namespace std; strint s1, s2; int leng; int main() { cin >> s1; for(int i = s1.size() - 1; i >= 0; i--) s2[leng++] = s1[i]; for(int i = 0; i < leng; i++) { if(s1[i]=='b') s2[i]='d; else if (s1[i] == 'd') s2[i] = 'b'; else if (s1[i] == 'p') s2[i] = 'q'; else if (s1[i] == 'q') s2[i] = 'p'; } if(!strcmp(s1,s2)) puts("Yes"); else puts("No"); return 0; }
s480605256
p03889
u807772568
1562102792
Python
Python (3.4.3)
py
Runtime Error
19
3956
375
n = list(input()) if n % 2 == 0: for i in range(len(n)//2): if n[i] =="b": if n[-(i+1)] != "d": print("No") exit() elif n[i] == "p": if n[-(i+1)] != "q": print("No") exit() elif n[i] == "d": if n[-(i+1)] != "b": print("No") exit() elif n[i] == "q": if n[-(i+1)] != "p": print("No") exit() print("Yes") else: print("No")
s300750344
p03889
u596421790
1552697559
Python
Python (3.4.3)
py
Runtime Error
17
2940
103
s = input() is s[::-1].translate(str.maketrans("bdpq","dbqp")) == s: print("Yes") else: print("No")
s310930879
p03889
u128914900
1542918546
Python
Python (3.4.3)
py
Runtime Error
19
3188
234
s = input() ss = s[::-1] for i,j in enumerate(ss): if j == "p": ss[i] = "q" elif j == "q": ss[i] = "p" elif j == "b": ss[i] = "d" else: ss[i] = "b" if ss == s: print("Yes") else: print("No")
s279398259
p03889
u488497128
1542918256
Python
Python (3.4.3)
py
Runtime Error
17
2940
189
import sys dct = {"b": "d", "d", "b", "p": "q", "q": "p"} S = sys.stdin.readline().strip() rev = "" for s in S[::-1]: rev += dct[s] if rev == S: print("Yes") else: print("No")
s606140076
p03889
u005260772
1538687915
Python
Python (2.7.6)
py
Runtime Error
10
2692
149
dict = { 'b' : 'd', 'd' : 'b', 'p' : 'q', 'q' : 'p' } s = raw_input() t = ''.join(map(lambda x : dict[x], list(S[::-1]))) print ['No', 'Yes'][s == t]
s516210688
p03889
u493069654
1523317829
Python
Python (3.4.3)
py
Runtime Error
122
3188
306
def mirror(a,b): S=set() S.add(a) S.add(b) T=list(S) T.sort() if T[0]=="b" and T[1]=="d": return True elif T[0]=="p" and T[1]=="q": return True else: return False St=input() N=len(St) for i in range(N): if not(mirror(St[i],St[N-i-1])): print("No") exit() print("Yes")
s145959165
p03889
u427014358
1480274804
Python
Python (2.7.6)
py
Runtime Error
17
2948
167
s = raw_input().rstrip() t = s s = s[::-1] s = s.replace("b", "d") s = s.replace("p", "q") s = s.replace("d", "b") s = s.replace("q", "p") print s == t * "YES" or "NO"
s556641937
p03891
u743614777
1583375694
Python
Python (3.4.3)
py
Runtime Error
17
3060
120
a,b,c=map(int,input().split()) print(a,b,c) print(a,b,-a-b+3*c) print(-2*a-b+4*c,c,2*a+b-2*c) print(a+b-c,-b+2*c,-a+2*c)
s142575127
p03891
u143509139
1578062963
Python
Python (3.4.3)
py
Runtime Error
17
3064
118
a,b,c=[input() for _ in range(3)] s=3*c print(a,b,s-a-b) print(2*s-2*a-b-2*c,c,2*a+b+c-s) print(a+b+2*c-s,s-b-c,s-a-c)
s409305998
p03891
u137833956
1480349602
Python
Python (3.4.3)
py
Runtime Error
23
3064
154
c = t - a - b d = t - a - g f = t - d - e i = t - g - h print("{} {} {}".format(a,b,c)) print("{} {} {}".format(d,e,f)) print("{} {} {}".format(g,h,i))
s107229106
p03891
u427014358
1480275380
Python
Python (2.7.6)
py
Runtime Error
16
2696
133
a,b,c = map(int, raw_input().split()) s = 3*c print a,b,s-a-b print s-(c+s-(s-a-b+s-a-c)),c,s-(s-a-b+s-a-c) print a+b-c,s-b-c,s-a-c
s861752408
p03891
u427014358
1480275275
Python
Python (2.7.6)
py
Runtime Error
16
2696
125
a,b,c = map(int, raw_input()) s = 3*c print a,b,s-a-b print s-(c+s-(s-a-b+s-a-c)),c,s-(s-a-b+s-a-c) print a+b-c,s-b-c,s-a-c
s611703456
p03892
u143509139
1578063607
Python
Python (3.4.3)
py
Runtime Error
20
3060
157
from fraction import gcd a,b,c,d=map(int,input().split()) if abs(c-a)==0 or abs(d-b)==0: print(0) else: x,y=abs(c-a),abs(d-b) g=gcd(x,y) print(x+y-g)
s952877087
p03892
u623819879
1562204791
Python
Python (3.4.3)
py
Runtime Error
18
2940
106
import math a,b,c,d=map(int,input().split()) x,y=abs(a-c),abs(b-d) g=math.gcd(x,y) print(g*(x//g+y//d-1))
s491248976
p03892
u623819879
1562204758
Python
Python (3.4.3)
py
Runtime Error
18
3060
105
import math a,b,c,d=map(int,input().split()) x,y=abs(a-c),abs(b-d) g=math.gcd(x,y) print(g*(x//g+y//d-1))
s169196725
p03892
u976162616
1512530732
Python
Python (3.4.3)
py
Runtime Error
17
3064
255
import math if __name__ == "__main__": A,B,C,D = map(int, input().split()) A -= C B -= D W = abs(A) H = abs(B) if W == 0 or H == 0: print (0) exit() res = W + H - 1 g = math.gcd(W, H) print (res - g + 1)
s295427777
p03892
u976162616
1512530698
Python
Python (3.4.3)
py
Runtime Error
18
3064
265
import math if __name__ == "__main__": A,B,C,D = map(int, input().split()) A -= C B -= D W = abs(A) H = abs(B) if W == 0 or H == 0: print (0) exit() res = W + H - 1 g = math.gcd(W, H) print (res - g + 1)
s199891032
p03892
u696805736
1499387437
Python
Python (3.4.3)
py
Runtime Error
18
3064
322
import math def main(): a,b,c,d = map(int,input().split()) a,c = min(a,c),max(a,c) b,d = min(b,d),max(b,d) c -= a a = 0 d -= b b = 0 if a==c or b==d: return 0 g = math.gcd(c,d) c//=g d//=g ct = c+d-1 return g*ct if __name__ == '__main__': print(main())
s534801750
p03892
u297467990
1480489939
Python
Python (3.4.3)
py
Runtime Error
24
3064
192
#!/usr/bin/env python3 import math a, b, c, d = map(int, input().split()) h = abs(a - c) w = abs(b - d) h1 = h // math.gcd(h, w) w1 = w // math.gcd(h, w) print((h1 + w1 - 1) * math.gcd(h, w))
s919168694
p03892
u198947665
1480351801
Python
Python (3.4.3)
py
Runtime Error
23
3064
158
import math A, B, C, D = map(int, input().split()) if A == C or B == D: print(0) exit() x = abs(A - C) y = abs(B - D) print(x + y - math.gcd(x, y))
s505470240
p03892
u198947665
1480351717
Python
Python (3.4.3)
py
Runtime Error
23
3064
147
import math A, B, C, D = map(int, input().split()) if A == C or B == D: print(0) x = abs(A - C) y = abs(B - D) print(x + y - math.gcd(x, y))
s510837126
p03892
u781091740
1480279187
Python
Python (3.4.3)
py
Runtime Error
24
3316
123
import math a,b,c,d=map(int,input().split()) c-=a d-=b g=math.gcd(max(c,d),min(c,d)) j=int(c/g) k=int(d/g) print((j+k-1)*g)
s865091067
p03892
u781091740
1480279098
Python
Python (3.4.3)
py
Runtime Error
23
3064
109
import math a,b,c,d=map(int,input().split()) c-=a d-=b g=math.gcd(c,d) j=int(c/g) k=int(d/g) print((j+k-1)*g)
s402284826
p03892
u781091740
1480279042
Python
Python (3.4.3)
py
Runtime Error
23
3064
101
import math a,b,c,d=map(int,input().split()) c-=a d-=b g=math.gcd(c,d) j=c//g k=d//g print((j+k-1)*g)
s980765110
p03892
u781091740
1480278984
Python
Python (3.4.3)
py
Runtime Error
23
3064
102
import math a,b,c,d=map(int,input().split()) c-=a;d-=b; g=math.gcd(c,d) j=c//g;k=d//g print((j+k-1)*g)
s189701604
p03892
u427014358
1480275555
Python
Python (2.7.6)
py
Runtime Error
17
2568
206
a,b,c,d = map(int, raw_input().split()) x = abs(c-a) y = abs(d-b) if x == 0 or y == 0: print 0 return def gcd(a,b): return a if b == 0 else gcd(b, a % b) e = gcd(x,y) x /= e y /= e print (x+y-1) * e
s858391302
p03893
u754022296
1582960860
Python
Python (3.4.3)
py
Runtime Error
17
2940
24
print(4<<int(input())-2)
s596566195
p03894
u102461423
1566088122
Python
Python (3.4.3)
py
Runtime Error
157
25916
416
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N,Q = map(int,input().split()) AB = [[int(x) for x in input().split()] for _ in range(Q)] cup = list(range(N+1)) + [0] se = set([0,1,2]) for a,b in AB: cup[a],cup[b] = cup[b],cup[a] for x in [a,b]: if cup[x] == 1: ball = x se.add(cup[ball-1]) se.add(cup[ball+1]) se.remove(0) answer = len(se) print(answer)
s548912520
p03894
u102461423
1566088051
Python
Python (3.4.3)
py
Runtime Error
161
25864
428
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) N,Q = map(int,input().split()) AB = [[int(x) for x in input().split()] for _ in range(Q)] cup = list(range(N+1)) + [0] se = set() se.add(1) se.add(2) for a,b in AB: cup[a],cup[b] = cup[b],cup[a] for x in [a,b]: if cup[x] == 1: ball = x se.add(cup[ball-1]) se.add(cup[ball+1]) se.discard(0) answer = len(se) print(answer)
s249041357
p03894
u272028993
1492660734
Python
Python (2.7.6)
py
Runtime Error
15
2696
453
n,q=map(int,raw_input().split()) exist=set([1]) cup=range(n+2) now=1 exist.add(cup[now-1]) exist.add(cup[now+1]) for i in xrange(q): a,b=map(int,raw_input().split()) if now==a:now=b elif now==b:now=a tmp=cup[a] cup[a]=cup[b] cup[b]=tmp exist.add(cup[now-1]) exist.add(cup[now+1]) exist.add(now-1) exist.add(now+1) exist=list(exist) ans=0 for i in xrange(len(exist)): if exist[i]!=0 and exist[i]!=n+1:ans+=1 print ans
s068934410
p03894
u296290704
1480387688
Python
Python (2.7.6)
py
Runtime Error
80
23124
164
j=lambda:map(int,raw_input().split()) n,q=j() u=1 c=[1]*3+[0]*(n-2)+[1] exec("a,b=d=j();u+=u in d and a+b-2*u;c[a],c[b]=c[b],c[a];c[u-1]=c[u+1]=1"*q) print sum(c)-2
s421238396
p03896
u296290704
1480548247
Python
Python (2.7.6)
py
Runtime Error
17
2696
132
n=input();print-(n==2)or"\n".join(" ".join(`(i+(j^1)if n>i*2and n%2<1and j<n-2else i+j)%n`for j in range(n-1))for i in range(1,n+1))
s132131281
p03896
u296290704
1480387115
Python
Python (2.7.6)
py
Runtime Error
20
3076
190
n=input() if n==2:print-1;exit(0) r=range(n-1) A=[[`1+(i+j+2)%n`for j in r]for i in[-1]+r] i=n/2-1 for j in range(i+1):A[j][i]=`j+i+1`;A[j][i-n]=`j+i+2` print"\n".join(" ".join(e)for e in A)
s655867985
p03901
u539402331
1545861380
Python
Python (3.4.3)
py
Runtime Error
18
2940
231
#include <bits/stdc++.h> using namespace std; int main(){ long long x; double p; cin>>x>>p; if(x%2){cout<<setprecision(20)<<(((double)x+1)/2)/p*100<<endl;} else{ cout<<setprecision(20)<<(((double)x)/2)/p*100<<endl;} }
s557178750
p03902
u226155577
1565670403
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
1241
import sys readline = sys.stdin.readline from math import log2 N, M = map(int, readline().split()) A = [list(map(int, readline().split())) for i in range(N)] B = max(max(Ai) for Ai in A) if M == 1: if N == 1 or all(A[i][0] < A[i+1][0] for i in range(N-1)): print("0") else: print("-1") exit(0) logB = log2(B) logBi = int(logB) INF = 10**18 def gen(P, t): if t <= logB: for k in range(t): for i in range(M-1): P[i+1] += P[i] else: for k in range(t): for i in range(min(logBi+2, M-1)): P[i+1] += P[i] for i in range(logBi+2, M): P[i] = INF T = [0]*N ans = 0 P = [0]*M for i in range(N-1): a0, a1 = A[i][:2] b0, b1 = A[i+1][:2] if a0 < b0: continue if a0 > b0: ans = -1 break t0 = T[i] v = max(t0*a0 + a1 - b1, 0) if v % b0 > 0: T[i+1] = t1 = (v + b0-1) // b0 ans += t1 continue t1 = v // b0 if t0 <= t1: P[:] = A[i+1] gen(P, t1 - t0) if P <= A[i]: t1 += 1 else: P[:] = A[i] gen(P, t0 - t1) if A[i+1] <= P: t1 += 1 T[i+1] = t1 ans += t1 print(ans)
s928283893
p03902
u226155577
1565670126
Python
Python (3.4.3)
py
Runtime Error
2106
45300
1192
from math import log2 N, M = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] B = max(max(Ai) for Ai in A) if M == 1: if N == 1 or all(A[i][0] < A[i+1][0] for i in range(N-1)): print("0") else: print("-1") exit(0) logB = log2(B) logBi = int(logB) INF = 10**18 def gen(P, t): if t <= logB: for k in range(t): for i in range(M-1): P[i+1] += P[i] else: for k in range(t): for i in range(min(logBi+2, M)): P[i+1] += P[i] for i in range(logBi+2, M): P[i] = INF T = [0]*N ans = 0 P = [0]*M for i in range(N-1): a0, a1 = A[i][:2] b0, b1 = A[i+1][:2] if a0 < b0: continue if a0 > b0: ans = -1 break t0 = T[i] v = max(t0*a0 + a1 - b1, 0) if v % b0 > 0: T[i+1] = t1 = (v + b0-1) // b0 ans += t1 continue t1 = v // b0 if t0 <= t1: P[:] = A[i+1] gen(P, t1 - t0) if P <= A[i]: t1 += 1 else: P[:] = A[i] gen(P, t0 - t1) if A[i+1] <= P: t1 += 1 T[i+1] = t1 ans += t1 print(ans)
s220932410
p03902
u226155577
1565669625
Python
Python (3.4.3)
py
Runtime Error
2106
45296
1173
from math import log2 N, M = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] B = max(max(Ai) for Ai in A) if M == 1: if all(A[i][0] <= A[i+1][0] for i in range(N-1)): print("0") else: print("-1") exit(0) logB = log2(B) logBi = int(logB) INF = 10**18 def gen(P, t): if t <= logB: for k in range(t): for i in range(M-1): P[i+1] += P[i] else: for k in range(t): for i in range(logBi+2): P[i+1] += P[i] for i in range(logBi+2, M): P[i] = INF T = [0]*N ans = 0 P = [0]*M for i in range(N-1): a0, a1 = A[i][:2] b0, b1 = A[i+1][:2] if a0 < b0: continue if a0 > b0: ans = -1 break t0 = T[i] v = max(t0*a0 + a1 - b1, 0) if v % b0 > 0: T[i+1] = t1 = (v + b0-1) // b0 ans += t1 continue t1 = v // b0 if t0 < t1: P[:] = A[i+1] gen(P, t1 - t0) if P < A[i]: t1 += 1 else: P[:] = A[i] gen(P, t0 - t1) if A[i+1] < P: t1 += 1 T[i+1] = t1 ans += t1 print(ans)
s877054331
p03902
u226155577
1565668971
Python
PyPy3 (2.4.0)
py
Runtime Error
178
38512
1159
from math import log2 N, M = map(int, input().split()) A = [list(map(int, input().split())) for i in range(N)] B = max(max(Ai) for Ai in A) if M == 1: if all(A[i][0] <= A[i+1][0] for i in range(N-1)): print("0") else: print("-1") exit(0) logB = log2(B) logBi = int(logB) INF = 10**18 def gen(P, t): if t <= B: for k in range(t): for i in range(M-1): P[i+1] += P[i] else: for k in range(t): for i in range(logBi+1): P[i+1] += P[i] for i in range(logBi+1, M): P[i] = INF T = [0]*N ans = 0 P = [0]*M for i in range(N-1): a0, a1 = A[i][:2] b0, b1 = A[i+1][:2] if a0 < b0: continue if a0 > b0: ans = -1 break t0 = T[i] v = t0*a0 + a1 - b1 if v % b0 > 0: T[i+1] = t1 = (v + b0-1) // b0 ans += t1 continue t1 = v // b0 if t0 < t1: P[:] = A[i+1] gen(P, t1-t0) if P < A[i]: t1 += 1 else: P[:] = A[i] gen(P, t0 - t1) if A[i+1] < P: t1 += 1 T[i+1] = t1 ans += t1 print(ans)
s076121153
p03903
u226155577
1482041135
Python
PyPy2 (5.6.0)
py
Runtime Error
920
80156
841
inputs=lambda:map(int,raw_input().split()) n, m = inputs() es = [inputs() for i in xrange(m)] es.sort(key=lambda x:x[2]) parent = range(n+1) def root(x): if x == parent[x]: return x parent[x] = root(parent[x]) return parent[x] def unite(x, y): px = root(x) py = root(y) if px < py: parent[py] = px else: parent[px] = py su = 0 g = [[] for i in xrange(n+1)] for c, a, b in es: if root(a) != root(b): unite(a, b) su += c g[a].append((b, c)) g[b].append((a, c)) import sys sys.setrecursionlimit(100000) dic = {} def dfs(s, v, prev, cost): dic[s,v] = cost for e, c in g[v]: if prev != e: dfs(s, e, v, max(cost, c)) for i in xrange(n): dfs(i+1, i+1, -1, 0) for i in xrange(input()): s, t = inputs() print su-dic[s,t]
s308818726
p03903
u226155577
1480662467
Python
PyPy2 (5.6.0)
py
Runtime Error
2720
139744
1649
n, m = map(int, raw_input().split()) que = [] for i in xrange(m): a, b, c = map(int, raw_input().split()) que.append((c, a, b)) que.sort() p = range(n) def root(x): if x!=p[x]: x=p[x]=root(p[x]) return x def unite(x, y): px = p[x] py = p[y] if px < py: p[py] = px else: p[px] = py su = 0 g = [[] for i in xrange(n)] dic = {(0, -1): 0} for c, a, b in que: a -= 1; b -= 1 if root(a) != root(b): unite(a, b) su += c g[a].append(b) g[b].append(a) dic[a, b] = dic[b, a] = c nl = n.bit_length() ps = [[0]*n for i in xrange(nl)] cs = [[0]*n for i in xrange(nl)] ds = [0]*n INF = 10**9+7 def dfs(v, p, d): ps[0][v] = p cs[0][v] = dic[v,p] ds[v] = d for e in g[v]: if e!=p:dfs(e, v, d+1) def init(s): dfs(s, -1, 0) for i in xrange(nl-1): p1 = ps[i+1]; p0 = ps[i] c1 = cs[i+1]; c0 = cs[i] for v in xrange(n): p1[v] = -1 if p0[v] < 0 else p0[p0[v]] c1[v] = INF if p0[v] < 0 else max(c0[v], c0[p0[v]]) init(0) def solve(u, v): res = 0 if ds[u] > ds[v]: u,v = v,u for k in xrange(nl-1): if (ds[v] - ds[u]) >> k & 1: res = max(res, cs[k][v]) v = ps[k][v] if u==v: return res for k in xrange(nl-1, -1, -1): pk = ps[k] if pk[u] != pk[v]: res = max(res, cs[k][u], cs[k][v]) u = pk[u]; v = pk[v] res = max(res, cs[0][u], cs[0][v]) return res for i in xrange(input()): s, t = map(int, raw_input().split()) try: print su - solve(s-1, t-1) except: exit(0)
s504661484
p03903
u226155577
1480662084
Python
PyPy2 (5.6.0)
py
Runtime Error
2452
139744
1608
n, m = map(int, raw_input().split()) que = [] for i in xrange(m): a, b, c = map(int, raw_input().split()) que.append((c, a, b)) que.sort() p = range(n) def root(x): if x!=p[x]: x=p[x]=root(p[x]) return x def unite(x, y): px = p[x] py = p[y] if px < py: p[py] = px else: p[px] = py su = 0 g = [[] for i in xrange(n)] dic = {(0, -1): 0} for c, a, b in que: a -= 1; b -= 1 if root(a) != root(b): unite(a, b) su += c g[a].append(b) g[b].append(a) dic[a, b] = dic[b, a] = c nl = n.bit_length() ps = [[0]*n for i in xrange(nl)] cs = [[0]*n for i in xrange(nl)] ds = [0]*n INF = 10**9+7 def dfs(v, p, d): ps[0][v] = p cs[0][v] = dic[v,p] ds[v] = d for e in g[v]: if e!=p:dfs(e, v, d+1) def init(s): dfs(s, -1, 0) for i in xrange(nl-1): p1 = ps[i+1]; p0 = ps[i] c1 = cs[i+1]; c0 = cs[i] for v in xrange(n): p1[v] = -1 if p0[v] < 0 else p0[p0[v]] c1[v] = INF if p0[v] < 0 else max(c0[v], c0[p0[v]]) init(0) def solve(u, v): res = 0 if ds[u] > ds[v]: u,v = v,u for k in xrange(nl-1): if (ds[v] - ds[u]) >> k & 1: res = max(res, cs[k][v]) v = ps[k][v] if u==v: return res for k in xrange(nl-1, -1, -1): pk = ps[k] if pk[u] != pk[v]: res = max(res, cs[k][u], cs[k][v]) u = pk[u]; v = pk[v] res = max(res, cs[0][u], cs[0][v]) return res for i in xrange(input()): s, t = map(int, raw_input().split()) print su - solve(s-1, t-1)
s200541960
p03903
u226155577
1480661848
Python
PyPy2 (5.6.0)
py
Runtime Error
2402
139744
1611
n, m = map(int, raw_input().split()) que = [] for i in xrange(m): a, b, c = map(int, raw_input().split()) que.append((c, a, b)) que.sort() p = range(n) def root(x): if x!=p[x]: x=p[x]=root(p[x]) return x def unite(x, y): px = p[x] py = p[y] if px < py: p[py] = px else: p[px] = py su = 0 g = [[] for i in xrange(n)] dic = {(0, -1): 0} for c, a, b in que: a -= 1; b -= 1 if root(a) != root(b): unite(a, b) su += c g[a].append(b) g[b].append(a) dic[a, b] = dic[b, a] = c nl = n.bit_length() ps = [[0]*n for i in xrange(nl)] cs = [[0]*n for i in xrange(nl)] ds = [0]*n INF = 10**9+7 def dfs(v, p, d): ps[0][v] = p cs[0][v] = dic[v,p] ds[v] = d for e in g[v]: if e!=p:dfs(e, v, d+1) def init(s): dfs(s, -1, 0) for i in xrange(nl-1): p1 = ps[i+1]; p0 = ps[i] c1 = cs[i+1]; c0 = cs[i] for v in xrange(n): p1[v] = -1 if p0[v] < 0 else p0[p0[v]] c1[v] = INF if c0[v] == INF else max(c0[v], c0[p0[v]]) init(0) def solve(u, v): res = 0 if ds[u] > ds[v]: u,v = v,u for k in xrange(nl-1): if (ds[v] - ds[u]) >> k & 1: res = max(res, cs[k][v]) v = ps[k][v] if u==v: return res for k in xrange(nl-1, -1, -1): pk = ps[k] if pk[u] != pk[v]: res = max(res, cs[k][u], cs[k][v]) u = pk[u]; v = pk[v] res = max(res, cs[0][u], cs[0][v]) return res for i in xrange(input()): s, t = map(int, raw_input().split()) print su - solve(s-1, t-1)
s358347342
p03903
u226155577
1480483623
Python
PyPy2 (5.6.0)
py
Runtime Error
38
8816
470
k = input() s = raw_input() left = 0; right = int(s) while 1: mid = (left + right) / 2 cnt = 0 now = 0 for c in s: now = 10*now + int(c) if now > mid: cnt += 1 now = int(c) if now > mid: cnt = 100003 break if cnt > k: if left == mid: break left = mid else: if right == mid: break right = mid print left+1
s627763603
p03904
u226155577
1480483395
Python
Python (2.7.6)
py
Runtime Error
38
2692
499
k = input() s = raw_input() if len(s) > 100: exit(1) left = 0; right = int(s) while 1: mid = (left + right) / 2 cnt = 0 now = 0 for c in s: now = 10*now + int(c) if now > mid: cnt += 1 now = int(c) if now > mid: cnt = 100003 break if cnt > k: if left == mid: break left = mid else: if right == mid: break right = mid print left+1
s865392800
p03905
u296290704
1495384676
Python
Python (2.7.6)
py
Runtime Error
509
24508
914
n = input() D = [tuple(map(int, raw_input().split())) for i in xrange(n)] if (not D[0][0] == D[1][1] == 0 or not D[0][1] == D[1][0] > 0 or any(i>1 and (d[0] == 0 or d[1] == 0) for i, d in enumerate(D))): print -1 exit(0) m = {} for i, d in enumerate(D): m[d] = m.get(d, 0) + 1 if i>0 else 0 P = D[:2] D.sort() cnt = 0 for x, y in D: if (x+1, y+1) in m: cnt += m[x+1, y+1] m[x+1, y+1] = 0 if (x+1, y-1) in m: cnt += m[x+1, y-1] m[x+1, y-1] = 0 def dfs(x, y, dd, used): used.add((x, y)) for dx, dy in dd: nx = x + dx; ny = y + dy if (nx, ny) in m and (nx, ny) not in used: dfs(nx, ny, dd, used) usedA = set(); usedB = set() dfs(P[0][0], P[0][1], [(1, 1), (1, 0), (1, -1)], usedA) dfs(P[1][0], P[1][1], [(1, 1), (0, 1), (-1, 1)], usedB) if len(m) == len(usedA) == len(usedB): print 2*n - 2 - cnt else: print -1
s380732877
p03909
u516525290
1600638033
Python
Python (3.8.2)
py
Runtime Error
20
8976
1288
#include<iostream> #include<stdio.h> //#include <bits/stdc++.h> #include<vector> #include<float.h> #include<iomanip> #include<algorithm> #include<string> #include<cstring> #include<math.h> #include<cmath> #include<sstream> #include<set> #include<map> #include<queue> #include<cassert> #include<cmath> #include<cstdint> #define INF 1e9 #define rep(i,n)for(int i=0;(i)<(int)(n);i++) #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++) #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i; #define vec(type,n) vector<type>(n) #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n)) #define ALL(a) (a).begin(),(a).end() #define chmin(a, b) a = min(a, b) #define chmax(a, b) a = max(a, b) #define pb push_back using namespace std; using ll = long long int; using Graph = vector<vector<int>>; using P = pair<ll, ll>; const int MOD = 1e9 + 7; const ll ZER = 0; int main(){ int h, w; cin >> h >> w; vector<vector<string>> s(h, vector<string>(w)); rep(i, h)rep(j, w){ cin >> s[i][j]; if(s[i][j] == "snuke"){ cout << (char)('A' + j) << i + 1 << endl; } } }
s697462938
p03909
u641446860
1598581564
Python
Python (3.8.2)
py
Runtime Error
25
9172
247
H, W = map(int, input().split()) flag = False for i in range(H): for j in range(W): s = input() if s == "snuke": print(chr(ord('A')+j)+str(i+1)) flag = True break if flag: break
s232851191
p03909
u091051505
1590802021
Python
Python (3.4.3)
py
Runtime Error
17
2940
193
a, b = map(int, input().split()) A = 'ABCDEFGHIJKLMN' ans = "" for i in range(a): t = list(input().split()) if 'snuke' in t: ans += A[t.index("snuke")] ans += str(i + 1) print(ans)
s647362814
p03909
u679909135
1589842691
Python
Python (3.4.3)
py
Runtime Error
18
3060
226
H,W=map(int,input().split()) S=[input().split() for i in range(H)] columns=["A","B","C","D","E","F","G","H","I","J"] for h in range(H): for w in range(W): if S[h][w]=="snuke": print(columns[w]+str(h+1))
s041194769
p03909
u679909135
1589842636
Python
Python (3.4.3)
py
Runtime Error
18
3060
218
H,W=map(int,input().split()) S=[input().split() for i in range(H)] columns=["A","B","C","D","E","F","G","H"] for h in range(H): for w in range(W): if S[h][w]=="snuke": print(columns[w]+str(h+1))
s876913410
p03909
u408375121
1589464359
Python
Python (3.8.2)
py
Runtime Error
22
9168
399
alpha = {1:'A', 2:'B', 3:'C', 4:'D', 5:'E', 6:'F', 7:'G', 8:'H', 9:'I', 10:'J', 11:'K', 12:'L', 13:'M', 14:'N', 15:'O', 16:'P', 17:'Q', 18:'R', 19:'S', 20:'T', 21:'U', 22:'V', 23:'W', 24:'X', 25:'Y', 26:'Z'} h, w = map(int, input().split()) for i in range(h): a = list(map(int, input().split())) for j in range(w): if a[j] == 'snuke': ans = alpha[j+1] + str(i+1) break print(ans)
s349020353
p03909
u457898721
1589236823
Python
Python (3.4.3)
py
Runtime Error
17
3060
201
h,w = map(int, input().split()) s = [list(input().split()) for _ in range(h)] al = list("ABCDEFGHIJ") i = -1 for v in s: i+=1 if "snuke" in v: print(al[s[i].index("snuke")]+str(i+1)) exit()
s553376307
p03909
u519939795
1588776458
Python
Python (3.4.3)
py
Runtime Error
17
3064
335
h,w=map(int,input().split()) alp=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] l=[] for i in range(h): a=list(map(str,input().split())) l.append(a) for j in range(w): for k in range(h): if l[j][k]=='snuke': print(str(alp[j])+str(k+1)) print(l)
s047432815
p03909
u652656291
1588531993
Python
Python (3.4.3)
py
Runtime Error
18
3060
156
h,w = map(int,input().split()) S = [map(int,input().split()) for _ in range(h)] for i,j in range(): if S[i][j] == 'snuke': print((i)*w+j+1) break
s346524772
p03909
u652656291
1588531845
Python
Python (3.4.3)
py
Runtime Error
17
2940
123
h,w = map(int,input().split()) S = [input() for _ in range(h*w)] for i in range(h*w): if S[i] == 'snuke': print(i+1)
s041272475
p03909
u652656291
1588531825
Python
Python (3.4.3)
py
Runtime Error
18
2940
127
h,w = map(int,input().split()) S = [int(input()) for _ in range(h*w)] for i in range(h*w): if S[i] == 'snuke': print(i+1)
s569114806
p03909
u843135954
1587776679
Python
Python (3.4.3)
py
Runtime Error
17
3064
404
import sys stdin = sys.stdin sys.setrecursionlimit(10**6) ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) nn = lambda: list(stdin.readline().split()) ns = lambda: stdin.readline().rstrip() h,w = na() co = ['A','B','C','D','E','F','G','H','I','J'] for i in range(h): s = nn() if 'snuke' in s: j = s.index('snuke') print(co[j]+str(i+1)) exit()
s645774424
p03909
u145600939
1587776588
Python
Python (3.4.3)
py
Runtime Error
17
2940
165
h,w = map(int,input().split()) for i in range(h): s = input().split() if 'snuke' in s: ans = ord('A') + s.index('snuke') print(ans + str(i+1)) break
s753863474
p03909
u970809473
1585277041
Python
Python (3.4.3)
py
Runtime Error
18
3060
215
h,w = map(int, input().split()) l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' for i in range(w): tmp = list(map(str, input().split())) if tmp.count('snuke') == 1: a = l[tmp.index('snuke')] b = str(i + 1) print(a + b)
s205512892
p03909
u984276646
1584547618
Python
Python (3.4.3)
py
Runtime Error
17
3060
234
H, W = map(int, input().split()) alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" S = [list(map(int, input().split())) for _ in range(H)] for i in range(H): for j in range(W): if S[i][j] == "snuke": print("{}{}".format(alpha[j], i+1))
s525385044
p03909
u859742379
1584062469
Python
Python (3.4.3)
py
Runtime Error
17
3060
234
h,w=map(int,input().split()) a=[[i for i in input().split()] for j in range(h)] p=[chr(i) for i in range(65,75)] for r in range(h): for c in range(w): if a[r][c]=="snuke": print(p[c]+str(r+1)) break
s533726380
p03909
u277177960
1580011167
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38384
190
H, W = map(int, intput().split()) M = [input().split() for _ in range(H)] for i, r in enumerate(M): for j, c in enumerate(r): if c == 'snuke': print("%s%d" %(chr(ord('A')+j), i))
s182757705
p03909
u268792407
1578869888
Python
Python (3.4.3)
py
Runtime Error
17
3064
276
h,w=map(int,input().split()) alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] for i in range(h): s=list(map(str,input().split())) for j in range(w): if s[i]=="snuke": print(alphabet[j]+str(i+1))
s371690512
p03909
u577914737
1577923274
Python
Python (3.4.3)
py
Runtime Error
18
3064
410
def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) a,b=(int(x) for x in input().split()) for i in range(a): for j in range(b): try: c = input() if c=='snuke': d = num2alpha(i) e = str(d)+j print(e) except EOFError: break
s365571957
p03909
u577914737
1577922285
Python
Python (3.4.3)
py
Runtime Error
18
3060
353
def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) a = int(input()) b = int(input()) for i in range(a): for j in range(b): c = input() if c=='snuke': d = num2alpha(i) e = str(d)+j print(e)
s440741240
p03909
u577914737
1577922224
Python
Python (3.4.3)
py
Runtime Error
17
3064
347
def num2alpha(num): if num<=26: return chr(64+num) elif num%26==0: return num2alpha(num//26-1)+chr(90) else: return num2alpha(num//26)+chr(64+num%26) a = int(input()) b = int(input()) for i in range(a): for j in range(b): c = input() if c=='snuke': d = num2alpha(i) e = d+j print(e)
s933823377
p03909
u827163276
1577767208
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38512
172
H,W = map(int,input().split()) alp = 'ABCDEFGHIJ' for i in range(H): for j,s in enumerate(input().split()): if s == 'snuke': print(alp[j]+str(i+1)) exit()
s269490726
p03909
u878326845
1577755256
Python
Python (3.4.3)
py
Runtime Error
17
3060
217
a,b=map(int,input().split()) ls = ["ABCDEFGHIJKLMNOPQRSTUVWXYZ"] x = [list(input().split()) for i in range(a)] for i in range(a): for j in range(b): if x[a][b] == "snuke": print(ls[a]+str(b+1)) break
s114846260
p03909
u864197622
1576976127
Python
Python (3.4.3)
py
Runtime Error
17
3060
165
H, W = map(int, input().split()) for i in range(H): S = input(split()) for j in range(W): if S[j] == "snuke": print(chr(65+j) + str(i+1))
s590992249
p03909
u677523557
1574952449
Python
Python (3.4.3)
py
Runtime Error
17
3060
236
H, W = map(int, input().split()) state = [list(map(str, input().split())) for _ in range(h)] A = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" for h in range(H): for w in range(W): if state[h][w] == 'snuke': ans = A[w] + str(h+1) print(ans)
s141723082
p03909
u445624660
1574269883
Python
Python (3.4.3)
py
Runtime Error
17
3060
439
# 解説を観たのでそれをやってみるバージョン # (最初に解いたやつは愚直に毎回最大値を求めていた(なんかしらんけど通った)) n = int(input()) cur = 0 target = 0 for i in range(1, n + 1): if i + cur >= n: target = i break cur += i remove_num = sum([i for i in range(1, target + 1)]) - n for i in range(1, target + 1): if i != remove_num: print(i)
s457786598
p03909
u753803401
1570669184
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38640
416
def slove(): import sys input = sys.stdin.readline d = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"] h, w = list(map(int, input().rstrip('\n').split())) for i in range(h): s = list(map(str, input().rstrip('\n').split())) for j in range(w): if s[j] == "snuke": print(d[j] + str(i+1)) exit() if __name__ == '__main__': slove()
s996174416
p03909
u811000506
1562994901
Python
Python (3.4.3)
py
Runtime Error
17
3060
255
H, W = map(int,input().split()) S = [list(map(str,input().split())) for i in range(H)] char = "ABCDEFGHIJ" for i in range(H): for j in range(W): if S[i][j] == "snuke": tmp = [i,j] ans = str(char[tmp[1]]) + str(tmp[0]+1) print(ans)
s092639735
p03909
u772588522
1562712745
Python
Python (3.4.3)
py
Runtime Error
22
3316
366
import re, sys input = sys.stdin.readline def my_index(l, x, default=False): if x in l: return l.index(x) else: return default h, w = map(int, input().split()) for i in range(h): col = my_index(input().split(), 'snuke') if col == False: row = i + 1 break alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' print(alphabet[col] + str(row))
s225529166
p03909
u077291787
1562506289
Python
Python (3.4.3)
py
Runtime Error
17
3064
359
# cf16-finalA - Where's Snuke? def main(): h, w = list(map(int, input().rstrip().split())) A = [input().rstrip().split() for _ in range(h)] S = "ABCDEFGHIJ" for i in range(h): for j in range(w): if A[i][j] == "snuke": print(S[j], i + 1, sep="") return if __name__ == "__main__": main()
s630123844
p03909
u077291787
1562506248
Python
Python (3.4.3)
py
Runtime Error
17
3064
386
# cf16-finalA - Where's Snuke? def main(): h, w = list(map(int, input().rstrip().split())) A = [input().rstrip().split() for _ in range(h)] S = "ABCDEFGHIJ" for i in range(h): for j in range(w): if A[i][j] == "snuke": print(S[j], i + 1, sep="") return else: print(A) if __name__ == "__main__": main()
s113320805
p03909
u303059352
1558153807
Python
Python (3.4.3)
py
Runtime Error
17
2940
181
alph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" a, b = ap(int, input().split()) for i in range(a): for j in range(b): if input() == "snuke": print(alph[j] + str(i + 1)) exit()
s013426194
p03909
u163320134
1555244150
Python
Python (3.4.3)
py
Runtime Error
18
3064
262
h,w=map(int,input().split()) disp=['A','B','C','D','E','F','G','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'] for i in range(h): arr=list(map(str,input.split())) for j in range(w): if arr[j]=='snuke': print(disp[j]+str(i))
s513321359
p03909
u932465688
1550350808
Python
Python (3.4.3)
py
Runtime Error
17
3064
254
H,W = map(int,input().split()) L = [] A = ['A','B','C','D','E','F','G','H','I','J'] for i in range(H): L.append(input().split()) for i in range(H): for j in range(W): if L[i][j] == 'snuke': k = i+1 l = A[j] break print(l+str(k))
s891792198
p03909
u740284863
1550297889
Python
Python (3.4.3)
py
Runtime Error
18
3060
268
h,w = map(int,input().split()) maps = [] for i in range(h): maps.append(list(map(str,input().split()))) for i in range(h): for j in range(w): if maps[i][j] == "snuke": print('{}{}'.format(chr(row.index('snuke')+65),i+1)) exit()
s508965233
p03909
u740284863
1550297860
Python
Python (3.4.3)
py
Runtime Error
18
3060
226
h,w = map(int,input().split()) maps = [] for i in range(h): maps.append(list(map(int,input().split()))) for i in range(h): for j in range(w): if maps[i][j] == "snuke": print(i+1) exit()
s158805687
p03909
u740284863
1550292378
Python
Python (3.4.3)
py
Runtime Error
18
3060
267
h,w = map(int,input().split()) maps = [] for i in range(h): maps.append(list(map(int,input().split()))) for i in range(h): for j in range(w): if maps[i][j] == "snuke": print('{}{}'.format(chr(row.index('snuke')+65),i+1)) exit()
s671474045
p03909
u740284863
1550292275
Python
Python (3.4.3)
py
Runtime Error
17
3060
252
h,w = map(int,input().split()) maps = [] for i in range(h): maps.append(list(map(int,input().split()))) for i in range(h): for j in range(w): if maps[i][j] == "snuke": print(chr(ord('A') + w) + str(h + 1)) exit()
s956271379
p03909
u785989355
1544044564
Python
Python (3.4.3)
py
Runtime Error
19
3064
1150
def itoa(i): if i==0: return "a" elif i==1: return "b" elif i==2: return "c" elif i==3: return "d" elif i==4: return "e" elif i==5: return "f" elif i==6: return "g" elif i==7: return "h" elif i==8: return "i" elif i==9: return "j" elif i==10: return "k" elif i==11: return "l" elif i==12: return "m" elif i==13: return "n" elif i==14: return "o" elif i==15: return "p" elif i==16: return "q" elif i==17: return "r" elif i==18: return "s" elif i==19: return "t" elif i==20: return "u" elif i==21: return "v" elif i==22: return "w" elif i==23: return "x" elif i==24: return "y" elif i==25: return "z" H,W = list(map(int,input().split())) S = [] for i in range(H): S.append(list(map(int,input().split()))) for i in range(H): for j in range(W): if S[i][j]=="snuke": print(itoa(j).upper()+str(i)) break