user_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
1 value
submission_id_v0
stringlengths
10
10
submission_id_v1
stringlengths
10
10
cpu_time_v0
int64
10
38.3k
cpu_time_v1
int64
0
24.7k
memory_v0
int64
2.57k
1.02M
memory_v1
int64
2.57k
869k
status_v0
stringclasses
1 value
status_v1
stringclasses
1 value
improvement_frac
float64
7.51
100
input
stringlengths
20
4.55k
target
stringlengths
17
3.34k
code_v0_loc
int64
1
148
code_v1_loc
int64
1
184
code_v0_num_chars
int64
13
4.55k
code_v1_num_chars
int64
14
3.34k
code_v0_no_empty_lines
stringlengths
21
6.88k
code_v1_no_empty_lines
stringlengths
20
4.93k
code_same
bool
1 class
relative_loc_diff_percent
float64
0
79.8
diff
sequence
diff_only_import_comment
bool
1 class
measured_runtime_v0
float64
0.01
4.45
measured_runtime_v1
float64
0.01
4.31
runtime_lift
float64
0
359
key
sequence
u460245024
p03078
python
s605567230
s186496807
1,164
42
140,520
4,976
Accepted
Accepted
96.39
import itertools X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) comb_ab = [] for a, b in itertools.product(A, B): comb_ab.append(sum([a, b])) comb_ab_top = sorted(comb_ab, reverse=True)[:K] comb_abc = [] for ab, c in itertools.product(comb_ab_top, C): comb_abc.append(sum([ab, c])) ans = sorted(comb_abc, reverse=True)[:K] print(*ans, sep='\n')
import heapq X, Y, Z, K = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse=True) B = sorted(list(map(int, input().split())), reverse=True) C = sorted(list(map(int, input().split())), reverse=True) Q = [] heapq.heappush(Q, (-1*(A[0]+B[0]+C[0]), 0, 0, 0)) registered = set() registered.add((0, 0, 0)) for _ in range(K): s, ai, bi, ci = heapq.heappop(Q) print((-s)) if ai+1 < X and (ai+1, bi, ci) not in registered: heapq.heappush(Q, (-1*(A[ai+1]+B[bi]+C[ci]), ai+1, bi, ci)) registered.add((ai+1, bi, ci)) if bi+1 < Y and (ai, bi+1, ci) not in registered: heapq.heappush(Q, (-1*(A[ai]+B[bi+1]+C[ci]), ai, bi+1, ci)) registered.add((ai, bi+1, ci)) if ci+1 < Z and (ai, bi, ci+1) not in registered: heapq.heappush(Q, (-1*(A[ai]+B[bi]+C[ci+1]), ai, bi, ci+1)) registered.add((ai, bi, ci+1))
19
24
500
907
import itertools X, Y, Z, K = map(int, input().split()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) comb_ab = [] for a, b in itertools.product(A, B): comb_ab.append(sum([a, b])) comb_ab_top = sorted(comb_ab, reverse=True)[:K] comb_abc = [] for ab, c in itertools.product(comb_ab_top, C): comb_abc.append(sum([ab, c])) ans = sorted(comb_abc, reverse=True)[:K] print(*ans, sep="\n")
import heapq X, Y, Z, K = list(map(int, input().split())) A = sorted(list(map(int, input().split())), reverse=True) B = sorted(list(map(int, input().split())), reverse=True) C = sorted(list(map(int, input().split())), reverse=True) Q = [] heapq.heappush(Q, (-1 * (A[0] + B[0] + C[0]), 0, 0, 0)) registered = set() registered.add((0, 0, 0)) for _ in range(K): s, ai, bi, ci = heapq.heappop(Q) print((-s)) if ai + 1 < X and (ai + 1, bi, ci) not in registered: heapq.heappush(Q, (-1 * (A[ai + 1] + B[bi] + C[ci]), ai + 1, bi, ci)) registered.add((ai + 1, bi, ci)) if bi + 1 < Y and (ai, bi + 1, ci) not in registered: heapq.heappush(Q, (-1 * (A[ai] + B[bi + 1] + C[ci]), ai, bi + 1, ci)) registered.add((ai, bi + 1, ci)) if ci + 1 < Z and (ai, bi, ci + 1) not in registered: heapq.heappush(Q, (-1 * (A[ai] + B[bi] + C[ci + 1]), ai, bi, ci + 1)) registered.add((ai, bi, ci + 1))
false
20.833333
[ "-import itertools", "+import heapq", "-X, Y, Z, K = map(int, input().split())", "-A = sorted(list(map(int, input().split())))", "-B = sorted(list(map(int, input().split())))", "-C = sorted(list(map(int, input().split())))", "-comb_ab = []", "-for a, b in itertools.product(A, B):", "- comb_ab.append(sum([a, b]))", "-comb_ab_top = sorted(comb_ab, reverse=True)[:K]", "-comb_abc = []", "-for ab, c in itertools.product(comb_ab_top, C):", "- comb_abc.append(sum([ab, c]))", "-ans = sorted(comb_abc, reverse=True)[:K]", "-print(*ans, sep=\"\\n\")", "+X, Y, Z, K = list(map(int, input().split()))", "+A = sorted(list(map(int, input().split())), reverse=True)", "+B = sorted(list(map(int, input().split())), reverse=True)", "+C = sorted(list(map(int, input().split())), reverse=True)", "+Q = []", "+heapq.heappush(Q, (-1 * (A[0] + B[0] + C[0]), 0, 0, 0))", "+registered = set()", "+registered.add((0, 0, 0))", "+for _ in range(K):", "+ s, ai, bi, ci = heapq.heappop(Q)", "+ print((-s))", "+ if ai + 1 < X and (ai + 1, bi, ci) not in registered:", "+ heapq.heappush(Q, (-1 * (A[ai + 1] + B[bi] + C[ci]), ai + 1, bi, ci))", "+ registered.add((ai + 1, bi, ci))", "+ if bi + 1 < Y and (ai, bi + 1, ci) not in registered:", "+ heapq.heappush(Q, (-1 * (A[ai] + B[bi + 1] + C[ci]), ai, bi + 1, ci))", "+ registered.add((ai, bi + 1, ci))", "+ if ci + 1 < Z and (ai, bi, ci + 1) not in registered:", "+ heapq.heappush(Q, (-1 * (A[ai] + B[bi] + C[ci + 1]), ai, bi, ci + 1))", "+ registered.add((ai, bi, ci + 1))" ]
false
0.040546
0.036266
1.118041
[ "s605567230", "s186496807" ]
u440566786
p03003
python
s747484338
s446619162
420
334
72,412
72,540
Accepted
Accepted
20.48
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda :sys.stdin.readline().rstrip() def resolve(): n,m=list(map(int,input().split())) S=list(map(int,input().split())) T=list(map(int,input().split())) C=[[0]*(m+1) for _ in range(n+1)] from itertools import product for i,j in product(list(range(n)),list(range(m))): dp=C[i][j]+1 if(S[i]==T[j]) else 0 C[i+1][j+1]=dp+C[i][j+1]+C[i+1][j]-C[i][j] C[i+1][j+1]%=MOD print((C[n][m]+1)) resolve()
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=lambda:sys.stdin.readline().rstrip() def resolve(): n,m=list(map(int,input().split())) S=list(map(int,input().split())) T=list(map(int,input().split())) C=[[0]*(m+1) for _ in range(n+1)] # dp の累積和を持つ for i in range(n): C[i][0]=1 for j in range(m): C[0][j]=1 for i in range(n): for j in range(m): if(S[i]==T[j]): C[i+1][j+1]+=C[i][j] C[i+1][j+1]+=C[i+1][j]+C[i][j+1]-C[i][j] C[i+1][j+1]%=MOD print(((C[-1][-1]+2)%MOD)) resolve()
17
21
520
597
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, m = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) C = [[0] * (m + 1) for _ in range(n + 1)] from itertools import product for i, j in product(list(range(n)), list(range(m))): dp = C[i][j] + 1 if (S[i] == T[j]) else 0 C[i + 1][j + 1] = dp + C[i][j + 1] + C[i + 1][j] - C[i][j] C[i + 1][j + 1] %= MOD print((C[n][m] + 1)) resolve()
import sys sys.setrecursionlimit(2147483647) INF = float("inf") MOD = 10**9 + 7 input = lambda: sys.stdin.readline().rstrip() def resolve(): n, m = list(map(int, input().split())) S = list(map(int, input().split())) T = list(map(int, input().split())) C = [[0] * (m + 1) for _ in range(n + 1)] # dp の累積和を持つ for i in range(n): C[i][0] = 1 for j in range(m): C[0][j] = 1 for i in range(n): for j in range(m): if S[i] == T[j]: C[i + 1][j + 1] += C[i][j] C[i + 1][j + 1] += C[i + 1][j] + C[i][j + 1] - C[i][j] C[i + 1][j + 1] %= MOD print(((C[-1][-1] + 2) % MOD)) resolve()
false
19.047619
[ "- C = [[0] * (m + 1) for _ in range(n + 1)]", "- from itertools import product", "-", "- for i, j in product(list(range(n)), list(range(m))):", "- dp = C[i][j] + 1 if (S[i] == T[j]) else 0", "- C[i + 1][j + 1] = dp + C[i][j + 1] + C[i + 1][j] - C[i][j]", "- C[i + 1][j + 1] %= MOD", "- print((C[n][m] + 1))", "+ C = [[0] * (m + 1) for _ in range(n + 1)] # dp の累積和を持つ", "+ for i in range(n):", "+ C[i][0] = 1", "+ for j in range(m):", "+ C[0][j] = 1", "+ for i in range(n):", "+ for j in range(m):", "+ if S[i] == T[j]:", "+ C[i + 1][j + 1] += C[i][j]", "+ C[i + 1][j + 1] += C[i + 1][j] + C[i][j + 1] - C[i][j]", "+ C[i + 1][j + 1] %= MOD", "+ print(((C[-1][-1] + 2) % MOD))" ]
false
0.035331
0.034935
1.01134
[ "s747484338", "s446619162" ]
u477977638
p03108
python
s417822552
s515085817
724
504
97,884
32,648
Accepted
Accepted
30.39
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) def main(): n,m=map(int,input().split()) uf=UnionFind(n) now=n*(n-1)//2 g=[] ans=[now] now=n*(n-1)//2 for i in range(m): a,b=map(int,input().split()) g.append((a-1,b-1)) #print(g) g=g[::-1] for a,b in g: now-=uf.size(a)*uf.size(b)*(1-uf.same(a,b)) ans.append(now) uf.union(a,b) ans=ans[:-1][::-1] print(*ans,sep="\n") if __name__ == "__main__": main()
import sys read = sys.stdin.buffer.read input = sys.stdin.readline input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return sys.stdin.read() def II(): return int(eval(input())) def MI(): return list(map(int,input().split())) def MF(): return list(map(float,input().split())) def LI(): return list(map(int,input().split())) def LF(): return list(map(float,input().split())) def TI(): return tuple(map(int,input().split())) # rstrip().decode('utf-8') #2320 #import numpy as np class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) def main(): n,m=MI() e=[] for _ in range(m): a,b=MI() a-=1 b-=1 e.append([a,b]) #print(e) UF=UnionFind(n) ans=[] tmp=n*(n-1)//2 for li in reversed(e): ans.append(tmp) a=li[0] b=li[1] if UF.same(a,b): continue aa=UF.parents[UF.find(a)] bb=UF.parents[UF.find(b)] #print(a,b,aa,bb) tmp-=aa*bb UF.union(a,b) print(("\n".join(str(i) for i in ans[::-1]))) if __name__ == "__main__": main()
87
102
1,783
2,195
import sys read = sys.stdin.buffer.read input = sys.stdin.buffer.readline inputs = sys.stdin.buffer.readlines class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots()) def main(): n, m = map(int, input().split()) uf = UnionFind(n) now = n * (n - 1) // 2 g = [] ans = [now] now = n * (n - 1) // 2 for i in range(m): a, b = map(int, input().split()) g.append((a - 1, b - 1)) # print(g) g = g[::-1] for a, b in g: now -= uf.size(a) * uf.size(b) * (1 - uf.same(a, b)) ans.append(now) uf.union(a, b) ans = ans[:-1][::-1] print(*ans, sep="\n") if __name__ == "__main__": main()
import sys read = sys.stdin.buffer.read input = sys.stdin.readline input = sys.stdin.buffer.readline # sys.setrecursionlimit(10**9) # from functools import lru_cache def RD(): return sys.stdin.read() def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MF(): return list(map(float, input().split())) def LI(): return list(map(int, input().split())) def LF(): return list(map(float, input().split())) def TI(): return tuple(map(int, input().split())) # rstrip().decode('utf-8') # 2320 # import numpy as np class UnionFind: def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] def group_count(self): return len(self.roots()) def all_group_members(self): return {r: self.members(r) for r in self.roots()} def __str__(self): return "\n".join("{}: {}".format(r, self.members(r)) for r in self.roots()) def main(): n, m = MI() e = [] for _ in range(m): a, b = MI() a -= 1 b -= 1 e.append([a, b]) # print(e) UF = UnionFind(n) ans = [] tmp = n * (n - 1) // 2 for li in reversed(e): ans.append(tmp) a = li[0] b = li[1] if UF.same(a, b): continue aa = UF.parents[UF.find(a)] bb = UF.parents[UF.find(b)] # print(a,b,aa,bb) tmp -= aa * bb UF.union(a, b) print(("\n".join(str(i) for i in ans[::-1]))) if __name__ == "__main__": main()
false
14.705882
[ "+input = sys.stdin.readline", "-inputs = sys.stdin.buffer.readlines", "+# sys.setrecursionlimit(10**9)", "+# from functools import lru_cache", "+def RD():", "+ return sys.stdin.read()", "+def II():", "+ return int(eval(input()))", "+", "+", "+def MI():", "+ return list(map(int, input().split()))", "+", "+", "+def MF():", "+ return list(map(float, input().split()))", "+", "+", "+def LI():", "+ return list(map(int, input().split()))", "+", "+", "+def LF():", "+ return list(map(float, input().split()))", "+", "+", "+def TI():", "+ return tuple(map(int, input().split()))", "+", "+", "+# rstrip().decode('utf-8')", "+# 2320", "+# import numpy as np", "- n, m = map(int, input().split())", "- uf = UnionFind(n)", "- now = n * (n - 1) // 2", "- g = []", "- ans = [now]", "- now = n * (n - 1) // 2", "- for i in range(m):", "- a, b = map(int, input().split())", "- g.append((a - 1, b - 1))", "- # print(g)", "- g = g[::-1]", "- for a, b in g:", "- now -= uf.size(a) * uf.size(b) * (1 - uf.same(a, b))", "- ans.append(now)", "- uf.union(a, b)", "- ans = ans[:-1][::-1]", "- print(*ans, sep=\"\\n\")", "+ n, m = MI()", "+ e = []", "+ for _ in range(m):", "+ a, b = MI()", "+ a -= 1", "+ b -= 1", "+ e.append([a, b])", "+ # print(e)", "+ UF = UnionFind(n)", "+ ans = []", "+ tmp = n * (n - 1) // 2", "+ for li in reversed(e):", "+ ans.append(tmp)", "+ a = li[0]", "+ b = li[1]", "+ if UF.same(a, b):", "+ continue", "+ aa = UF.parents[UF.find(a)]", "+ bb = UF.parents[UF.find(b)]", "+ # print(a,b,aa,bb)", "+ tmp -= aa * bb", "+ UF.union(a, b)", "+ print((\"\\n\".join(str(i) for i in ans[::-1])))" ]
false
0.036919
0.037042
0.996667
[ "s417822552", "s515085817" ]
u162893962
p02791
python
s988601003
s079966477
133
99
26,012
24,744
Accepted
Accepted
25.56
N = int(eval(input())) ps = [int(i) for i in input().split()] cnt = 0 mark = ps[0] for p in ps: if mark >= p: cnt += 1 mark = min(mark, p) print(cnt)
N = int(eval(input())) ps = [int(i) for i in input().split()] cnt = 1 mark = ps[0] for p in ps[1:]: if mark >= p: cnt += 1 mark = p print(cnt)
11
11
176
169
N = int(eval(input())) ps = [int(i) for i in input().split()] cnt = 0 mark = ps[0] for p in ps: if mark >= p: cnt += 1 mark = min(mark, p) print(cnt)
N = int(eval(input())) ps = [int(i) for i in input().split()] cnt = 1 mark = ps[0] for p in ps[1:]: if mark >= p: cnt += 1 mark = p print(cnt)
false
0
[ "-cnt = 0", "+cnt = 1", "-for p in ps:", "+for p in ps[1:]:", "- mark = min(mark, p)", "+ mark = p" ]
false
0.065023
0.044865
1.449314
[ "s988601003", "s079966477" ]
u401686269
p02956
python
s529369241
s996811181
1,979
1,487
214,256
208,496
Accepted
Accepted
24.86
# 解説放送の方針 # 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。 # 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT1本で済むようにした N = int(eval(input())) xy = [tuple(map(int,input().split())) for _ in range(N)] mod = 998244353 class BIT: '''https://tjkendev.github.io/procon-library/python/range_query/bit.html''' def __init__(self, n): self.n = n self.data = [0]*(n+1) self.el = [0]*(n+1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): self.el[i] += x while i <= self.n: self.data[i] += x i += i & -i def query(self, i, j=None): if j is None: return self.el[i] return self.sum(j) - self.sum(i) # 平面走査のためのソート(高速化のため1次元にしてソート) xy2 = [] for i in range(N): x,y = xy[i] x += 10**9 y += 10**9 xy2.append(y<<80 | x << 40 | i) # ソート後の復元+座標圧縮用の辞書作成 # 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。 xy2 = sorted(xy2) mask = (1<<40)-1 y_order=[0]*N y_compress={} for j,y in enumerate(xy2): i = y & mask y >>= 40 x = y & mask x -= 10**9 y >>= 40 y -= 10**9 y_order[i] = j y_compress[y] = j+1 xy2 = [] for i in range(N): x,y = xy[i] x += 10**9 y += 10**9 xy2.append(x<<80 | y << 40 | i) xy2 = sorted(xy2) mask = (1<<40)-1 bit=BIT(N) ans = 0 memo=[0]*N # いちいち2^nを計算していると遅いのでメモ化 def pow2(x): if memo[x-1]:return memo[x-1] out = pow(2,x,mod) memo[x-1] = out return out for x in xy2: i = x & mask x >>= 40 y = x & mask y -= 10**9 x >>= 40 x -= 10**9 y = y_compress[y] bit.add(y,1) ''' 今現在みている点より左上と左下にある点の個数(今の点は含まない。以下同じ)。 BITを使って求める。 ''' n1 = bit.query(y-1,N)-1 n2 = bit.query(0,y)-1 ''' 右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。 そこからn1(走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。 ''' n3 = N-y-n1 n4 = y-n2-1 prod14 = (pow2(n1)-1)*(pow2(n4)-1)*pow2(n2+n3) %mod prod23 = (pow2(n2)-1)*(pow2(n3)-1)*pow2(n1+n4) %mod prod1234 = (pow2(n1)-1)*(pow2(n4)-1)*(pow2(n2)-1)*(pow2(n3)-1) %mod ans += pow2(N-1)+prod14+prod23-prod1234 ans %= mod print(ans)
# 解説放送の方針 # 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。 # 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT1本で済むようにした N = int(eval(input())) xy = [tuple(map(int,input().split())) for _ in range(N)] mod = 998244353 class BIT: '''https://tjkendev.github.io/procon-library/python/range_query/bit.html''' def __init__(self, n): self.n = n self.data = [0]*(n+1) self.el = [0]*(n+1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): self.el[i] += x while i <= self.n: self.data[i] += x i += i & -i def query(self, i, j=None): if j is None: return self.el[i] return self.sum(j) - self.sum(i) # 平面走査のためのソート(高速化のため1次元にしてソート) xy2 = [] for i in range(N): x,y = xy[i] x += 10**9 y += 10**9 xy2.append(y<<80 | x << 40 | i) # ソート後の復元+座標圧縮用の辞書作成 # 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。 xy2 = sorted(xy2) mask = (1<<40)-1 y_order=[0]*N y_compress={} for j,y in enumerate(xy2): i = y & mask y >>= 40 x = y & mask x -= 10**9 y >>= 40 y -= 10**9 y_order[i] = j y_compress[y] = j+1 xy2 = [] for i in range(N): x,y = xy[i] x += 10**9 y += 10**9 xy2.append(x<<80 | y << 40 | i) xy2 = sorted(xy2) mask = (1<<40)-1 bit=BIT(N) ans = 0 memo=[0]*N # いちいち2^nを計算していると遅いのでテーブル作成 pow2 = [1]*(N+1) for i in range(1,N+1): pow2[i] = pow2[i-1]*2 %mod for x in xy2: i = x & mask x >>= 40 y = x & mask y -= 10**9 x >>= 40 x -= 10**9 y = y_compress[y] bit.add(y,1) ''' 今現在みている点より左上と左下にある点の個数(今の点は含まない。以下同じ)。 BITを使って求める。 ''' n1 = bit.query(y-1,N)-1 n2 = bit.query(0,y)-1 ''' 右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。 そこからn1(走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。 ''' n3 = N-y-n1 n4 = y-n2-1 prod14 = (pow2[n1]-1)*(pow2[n4]-1)*pow2[n2+n3] %mod prod23 = (pow2[n2]-1)*(pow2[n3]-1)*pow2[n1+n4] %mod prod1234 = (pow2[n1]-1)*(pow2[n4]-1)*(pow2[n2]-1)*(pow2[n3]-1) %mod ans += pow2[N-1]+prod14+prod23-prod1234 ans %= mod print(ans)
105
103
2,200
2,173
# 解説放送の方針 # 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。 # 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT1本で済むようにした N = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(N)] mod = 998244353 class BIT: """https://tjkendev.github.io/procon-library/python/range_query/bit.html""" def __init__(self, n): self.n = n self.data = [0] * (n + 1) self.el = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): self.el[i] += x while i <= self.n: self.data[i] += x i += i & -i def query(self, i, j=None): if j is None: return self.el[i] return self.sum(j) - self.sum(i) # 平面走査のためのソート(高速化のため1次元にしてソート) xy2 = [] for i in range(N): x, y = xy[i] x += 10**9 y += 10**9 xy2.append(y << 80 | x << 40 | i) # ソート後の復元+座標圧縮用の辞書作成 # 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。 xy2 = sorted(xy2) mask = (1 << 40) - 1 y_order = [0] * N y_compress = {} for j, y in enumerate(xy2): i = y & mask y >>= 40 x = y & mask x -= 10**9 y >>= 40 y -= 10**9 y_order[i] = j y_compress[y] = j + 1 xy2 = [] for i in range(N): x, y = xy[i] x += 10**9 y += 10**9 xy2.append(x << 80 | y << 40 | i) xy2 = sorted(xy2) mask = (1 << 40) - 1 bit = BIT(N) ans = 0 memo = [0] * N # いちいち2^nを計算していると遅いのでメモ化 def pow2(x): if memo[x - 1]: return memo[x - 1] out = pow(2, x, mod) memo[x - 1] = out return out for x in xy2: i = x & mask x >>= 40 y = x & mask y -= 10**9 x >>= 40 x -= 10**9 y = y_compress[y] bit.add(y, 1) """ 今現在みている点より左上と左下にある点の個数(今の点は含まない。以下同じ)。 BITを使って求める。 """ n1 = bit.query(y - 1, N) - 1 n2 = bit.query(0, y) - 1 """ 右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。 そこからn1(走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。 """ n3 = N - y - n1 n4 = y - n2 - 1 prod14 = (pow2(n1) - 1) * (pow2(n4) - 1) * pow2(n2 + n3) % mod prod23 = (pow2(n2) - 1) * (pow2(n3) - 1) * pow2(n1 + n4) % mod prod1234 = (pow2(n1) - 1) * (pow2(n4) - 1) * (pow2(n2) - 1) * (pow2(n3) - 1) % mod ans += pow2(N - 1) + prod14 + prod23 - prod1234 ans %= mod print(ans)
# 解説放送の方針 # 平面走査をし、各点について、左上、左下、右上、右下にある点を数え、計算する。 # 解説放送ではBITを2本使っていたが、座標圧縮の結果を利用してBIT1本で済むようにした N = int(eval(input())) xy = [tuple(map(int, input().split())) for _ in range(N)] mod = 998244353 class BIT: """https://tjkendev.github.io/procon-library/python/range_query/bit.html""" def __init__(self, n): self.n = n self.data = [0] * (n + 1) self.el = [0] * (n + 1) def sum(self, i): s = 0 while i > 0: s += self.data[i] i -= i & -i return s def add(self, i, x): self.el[i] += x while i <= self.n: self.data[i] += x i += i & -i def query(self, i, j=None): if j is None: return self.el[i] return self.sum(j) - self.sum(i) # 平面走査のためのソート(高速化のため1次元にしてソート) xy2 = [] for i in range(N): x, y = xy[i] x += 10**9 y += 10**9 xy2.append(y << 80 | x << 40 | i) # ソート後の復元+座標圧縮用の辞書作成 # 座標圧縮: 小さいyから順に1,2,3...と値を割り振る。 xy2 = sorted(xy2) mask = (1 << 40) - 1 y_order = [0] * N y_compress = {} for j, y in enumerate(xy2): i = y & mask y >>= 40 x = y & mask x -= 10**9 y >>= 40 y -= 10**9 y_order[i] = j y_compress[y] = j + 1 xy2 = [] for i in range(N): x, y = xy[i] x += 10**9 y += 10**9 xy2.append(x << 80 | y << 40 | i) xy2 = sorted(xy2) mask = (1 << 40) - 1 bit = BIT(N) ans = 0 memo = [0] * N # いちいち2^nを計算していると遅いのでテーブル作成 pow2 = [1] * (N + 1) for i in range(1, N + 1): pow2[i] = pow2[i - 1] * 2 % mod for x in xy2: i = x & mask x >>= 40 y = x & mask y -= 10**9 x >>= 40 x -= 10**9 y = y_compress[y] bit.add(y, 1) """ 今現在みている点より左上と左下にある点の個数(今の点は含まない。以下同じ)。 BITを使って求める。 """ n1 = bit.query(y - 1, N) - 1 n2 = bit.query(0, y) - 1 """ 右上と右下。座標圧縮の結果を利用。(N-y(座標圧縮済))はある点より上にある点の総数。 そこからn1(走査済みの点の個数)を引くことで、まだ走査していない点の個数を求めることができる。 """ n3 = N - y - n1 n4 = y - n2 - 1 prod14 = (pow2[n1] - 1) * (pow2[n4] - 1) * pow2[n2 + n3] % mod prod23 = (pow2[n2] - 1) * (pow2[n3] - 1) * pow2[n1 + n4] % mod prod1234 = (pow2[n1] - 1) * (pow2[n4] - 1) * (pow2[n2] - 1) * (pow2[n3] - 1) % mod ans += pow2[N - 1] + prod14 + prod23 - prod1234 ans %= mod print(ans)
false
1.904762
[ "-# いちいち2^nを計算していると遅いのでメモ化", "-def pow2(x):", "- if memo[x - 1]:", "- return memo[x - 1]", "- out = pow(2, x, mod)", "- memo[x - 1] = out", "- return out", "-", "-", "+# いちいち2^nを計算していると遅いのでテーブル作成", "+pow2 = [1] * (N + 1)", "+for i in range(1, N + 1):", "+ pow2[i] = pow2[i - 1] * 2 % mod", "- prod14 = (pow2(n1) - 1) * (pow2(n4) - 1) * pow2(n2 + n3) % mod", "- prod23 = (pow2(n2) - 1) * (pow2(n3) - 1) * pow2(n1 + n4) % mod", "- prod1234 = (pow2(n1) - 1) * (pow2(n4) - 1) * (pow2(n2) - 1) * (pow2(n3) - 1) % mod", "- ans += pow2(N - 1) + prod14 + prod23 - prod1234", "+ prod14 = (pow2[n1] - 1) * (pow2[n4] - 1) * pow2[n2 + n3] % mod", "+ prod23 = (pow2[n2] - 1) * (pow2[n3] - 1) * pow2[n1 + n4] % mod", "+ prod1234 = (pow2[n1] - 1) * (pow2[n4] - 1) * (pow2[n2] - 1) * (pow2[n3] - 1) % mod", "+ ans += pow2[N - 1] + prod14 + prod23 - prod1234" ]
false
0.069338
0.073991
0.937122
[ "s529369241", "s996811181" ]
u401686269
p02565
python
s826279144
s134486990
692
371
10,208
10,116
Accepted
Accepted
46.39
import sys class SCC: ''' SCC class with non-recursive DFS. ''' def __init__(self,N): self.N = N self.G1 = [[] for _ in range(N)] self.G2 = [[] for _ in range(N)] def add_edge(self,a,b): self.G1[a].append(b) self.G2[b].append(a) def scc(self): self.seen = [0]*self.N self.postorder=[-1]*self.N self.order = 0 for i in range(self.N): if self.seen[i]:continue self._dfs(i) self.seen = [0]*self.N scclist = [] for i in self._argsort(self.postorder,reverse=True): if self.seen[i]:continue cc = self._dfs2(i) scclist.append(cc) return scclist def _argsort(self,arr,reverse=False): shift = self.N.bit_length()+2 tmp = sorted([arr[i]<<shift | i for i in range(len(arr))],reverse=reverse) mask = (1<<shift) - 1 return [tmp[i] & mask for i in range(len(arr))] def _dfs(self,v0): todo = [~v0, v0] while todo: v = todo.pop() if v >= 0: self.seen[v] = 1 for next_v in self.G1[v]: if self.seen[next_v]: continue todo.append(~next_v) todo.append(next_v) else: if self.postorder[~v] == -1: self.postorder[~v] = self.order self.order += 1 return def _dfs2(self,v): todo = [v] self.seen[v] = 1 cc = [v] while todo: v = todo.pop() for next_v in self.G2[v]: if self.seen[next_v]: continue self.seen[next_v] = 1 todo.append(next_v) cc.append(next_v) return cc class TwoSAT: def __init__(self,N): self.N = N self.scc = SCC(2*N) self.flag=-1 def add_clause(self,i,f,j,g): self.scc.add_edge(f*N+i,(1^g)*N+j) self.scc.add_edge(g*N+j,(1^f)*N+i) def satisfiable(self): if self.flag==-1: self.scclist = self.scc.scc() self.order = {j:i for i,scc in enumerate(self.scclist) for j in scc} self.flag = True self.ans = [0]*self.N for i in range(self.N): if self.order[i] > self.order[self.N+i]: self.ans[i] = 1 continue elif self.order[i] == self.order[i+self.N]: self.flag = False return self.flag return self.flag else: return self.flag def answer(self): return self.ans N,D=map(int,input().split()) xy = [tuple(map(int,input().split())) for _ in range(N)] ts=TwoSAT(N) for i in range(N-1): for j in range(i+1,N): for k1,k2 in [(0,0),(0,1),(1,0),(1,1)]: pos1,pos2 = xy[i][k1],xy[j][k2] if abs(pos2-pos1)<D: ts.add_clause(i,k1^1,j,k2^1) if ts.satisfiable(): print('Yes') print(*[xy[i][ts.ans[i]] for i in range(N)],sep="\n") else: print('No')
import sys class SCC: ''' SCC class with non-recursive DFS. ''' def __init__(self,N): self.N = N self.G1 = [[] for _ in range(N)] self.G2 = [[] for _ in range(N)] def add_edge(self,a,b): self.G1[a].append(b) self.G2[b].append(a) def scc(self): self.seen = [0]*self.N self.postorder=[-1]*self.N self.order = 0 for i in range(self.N): if self.seen[i]:continue self._dfs(i) self.seen = [0]*self.N scclist = [] for i in self._argsort(self.postorder,reverse=True): if self.seen[i]:continue cc = self._dfs2(i) scclist.append(cc) return scclist def _argsort(self,arr,reverse=False): shift = self.N.bit_length()+2 tmp = sorted([arr[i]<<shift | i for i in range(len(arr))],reverse=reverse) mask = (1<<shift) - 1 return [tmp[i] & mask for i in range(len(arr))] def _dfs(self,v0): todo = [~v0, v0] while todo: v = todo.pop() if v >= 0: self.seen[v] = 1 for next_v in self.G1[v]: if self.seen[next_v]: continue todo.append(~next_v) todo.append(next_v) else: if self.postorder[~v] == -1: self.postorder[~v] = self.order self.order += 1 return def _dfs2(self,v): todo = [v] self.seen[v] = 1 cc = [v] while todo: v = todo.pop() for next_v in self.G2[v]: if self.seen[next_v]: continue self.seen[next_v] = 1 todo.append(next_v) cc.append(next_v) return cc class TwoSAT: def __init__(self,N): self.N = N self.scc = SCC(2*N) self.flag=-1 def add_clause(self,i,f,j,g): self.scc.add_edge(f*self.N+i,(1^g)*self.N+j) self.scc.add_edge(g*self.N+j,(1^f)*self.N+i) def satisfiable(self): if self.flag==-1: self.scclist = self.scc.scc() self.order = {j:i for i,scc in enumerate(self.scclist) for j in scc} self.flag = True self.ans = [0]*self.N for i in range(self.N): if self.order[i] > self.order[self.N+i]: self.ans[i] = 1 continue elif self.order[i] == self.order[i+self.N]: self.flag = False return self.flag return self.flag else: return self.flag def answer(self): return self.ans def main(): N,D=map(int,input().split()) xy = [tuple(map(int,input().split())) for _ in range(N)] ts=TwoSAT(N) for i in range(N-1): for j in range(i+1,N): for k1,k2 in [(0,0),(0,1),(1,0),(1,1)]: pos1,pos2 = xy[i][k1],xy[j][k2] if abs(pos2-pos1)<D: ts.add_clause(i,k1^1,j,k2^1) if ts.satisfiable(): print('Yes') print(*[xy[i][ts.ans[i]] for i in range(N)],sep="\n") else: print('No') if __name__=="__main__": main()
111
115
2,820
2,915
import sys class SCC: """ SCC class with non-recursive DFS. """ def __init__(self, N): self.N = N self.G1 = [[] for _ in range(N)] self.G2 = [[] for _ in range(N)] def add_edge(self, a, b): self.G1[a].append(b) self.G2[b].append(a) def scc(self): self.seen = [0] * self.N self.postorder = [-1] * self.N self.order = 0 for i in range(self.N): if self.seen[i]: continue self._dfs(i) self.seen = [0] * self.N scclist = [] for i in self._argsort(self.postorder, reverse=True): if self.seen[i]: continue cc = self._dfs2(i) scclist.append(cc) return scclist def _argsort(self, arr, reverse=False): shift = self.N.bit_length() + 2 tmp = sorted([arr[i] << shift | i for i in range(len(arr))], reverse=reverse) mask = (1 << shift) - 1 return [tmp[i] & mask for i in range(len(arr))] def _dfs(self, v0): todo = [~v0, v0] while todo: v = todo.pop() if v >= 0: self.seen[v] = 1 for next_v in self.G1[v]: if self.seen[next_v]: continue todo.append(~next_v) todo.append(next_v) else: if self.postorder[~v] == -1: self.postorder[~v] = self.order self.order += 1 return def _dfs2(self, v): todo = [v] self.seen[v] = 1 cc = [v] while todo: v = todo.pop() for next_v in self.G2[v]: if self.seen[next_v]: continue self.seen[next_v] = 1 todo.append(next_v) cc.append(next_v) return cc class TwoSAT: def __init__(self, N): self.N = N self.scc = SCC(2 * N) self.flag = -1 def add_clause(self, i, f, j, g): self.scc.add_edge(f * N + i, (1 ^ g) * N + j) self.scc.add_edge(g * N + j, (1 ^ f) * N + i) def satisfiable(self): if self.flag == -1: self.scclist = self.scc.scc() self.order = {j: i for i, scc in enumerate(self.scclist) for j in scc} self.flag = True self.ans = [0] * self.N for i in range(self.N): if self.order[i] > self.order[self.N + i]: self.ans[i] = 1 continue elif self.order[i] == self.order[i + self.N]: self.flag = False return self.flag return self.flag else: return self.flag def answer(self): return self.ans N, D = map(int, input().split()) xy = [tuple(map(int, input().split())) for _ in range(N)] ts = TwoSAT(N) for i in range(N - 1): for j in range(i + 1, N): for k1, k2 in [(0, 0), (0, 1), (1, 0), (1, 1)]: pos1, pos2 = xy[i][k1], xy[j][k2] if abs(pos2 - pos1) < D: ts.add_clause(i, k1 ^ 1, j, k2 ^ 1) if ts.satisfiable(): print("Yes") print(*[xy[i][ts.ans[i]] for i in range(N)], sep="\n") else: print("No")
import sys class SCC: """ SCC class with non-recursive DFS. """ def __init__(self, N): self.N = N self.G1 = [[] for _ in range(N)] self.G2 = [[] for _ in range(N)] def add_edge(self, a, b): self.G1[a].append(b) self.G2[b].append(a) def scc(self): self.seen = [0] * self.N self.postorder = [-1] * self.N self.order = 0 for i in range(self.N): if self.seen[i]: continue self._dfs(i) self.seen = [0] * self.N scclist = [] for i in self._argsort(self.postorder, reverse=True): if self.seen[i]: continue cc = self._dfs2(i) scclist.append(cc) return scclist def _argsort(self, arr, reverse=False): shift = self.N.bit_length() + 2 tmp = sorted([arr[i] << shift | i for i in range(len(arr))], reverse=reverse) mask = (1 << shift) - 1 return [tmp[i] & mask for i in range(len(arr))] def _dfs(self, v0): todo = [~v0, v0] while todo: v = todo.pop() if v >= 0: self.seen[v] = 1 for next_v in self.G1[v]: if self.seen[next_v]: continue todo.append(~next_v) todo.append(next_v) else: if self.postorder[~v] == -1: self.postorder[~v] = self.order self.order += 1 return def _dfs2(self, v): todo = [v] self.seen[v] = 1 cc = [v] while todo: v = todo.pop() for next_v in self.G2[v]: if self.seen[next_v]: continue self.seen[next_v] = 1 todo.append(next_v) cc.append(next_v) return cc class TwoSAT: def __init__(self, N): self.N = N self.scc = SCC(2 * N) self.flag = -1 def add_clause(self, i, f, j, g): self.scc.add_edge(f * self.N + i, (1 ^ g) * self.N + j) self.scc.add_edge(g * self.N + j, (1 ^ f) * self.N + i) def satisfiable(self): if self.flag == -1: self.scclist = self.scc.scc() self.order = {j: i for i, scc in enumerate(self.scclist) for j in scc} self.flag = True self.ans = [0] * self.N for i in range(self.N): if self.order[i] > self.order[self.N + i]: self.ans[i] = 1 continue elif self.order[i] == self.order[i + self.N]: self.flag = False return self.flag return self.flag else: return self.flag def answer(self): return self.ans def main(): N, D = map(int, input().split()) xy = [tuple(map(int, input().split())) for _ in range(N)] ts = TwoSAT(N) for i in range(N - 1): for j in range(i + 1, N): for k1, k2 in [(0, 0), (0, 1), (1, 0), (1, 1)]: pos1, pos2 = xy[i][k1], xy[j][k2] if abs(pos2 - pos1) < D: ts.add_clause(i, k1 ^ 1, j, k2 ^ 1) if ts.satisfiable(): print("Yes") print(*[xy[i][ts.ans[i]] for i in range(N)], sep="\n") else: print("No") if __name__ == "__main__": main()
false
3.478261
[ "- self.scc.add_edge(f * N + i, (1 ^ g) * N + j)", "- self.scc.add_edge(g * N + j, (1 ^ f) * N + i)", "+ self.scc.add_edge(f * self.N + i, (1 ^ g) * self.N + j)", "+ self.scc.add_edge(g * self.N + j, (1 ^ f) * self.N + i)", "-N, D = map(int, input().split())", "-xy = [tuple(map(int, input().split())) for _ in range(N)]", "-ts = TwoSAT(N)", "-for i in range(N - 1):", "- for j in range(i + 1, N):", "- for k1, k2 in [(0, 0), (0, 1), (1, 0), (1, 1)]:", "- pos1, pos2 = xy[i][k1], xy[j][k2]", "- if abs(pos2 - pos1) < D:", "- ts.add_clause(i, k1 ^ 1, j, k2 ^ 1)", "-if ts.satisfiable():", "- print(\"Yes\")", "- print(*[xy[i][ts.ans[i]] for i in range(N)], sep=\"\\n\")", "-else:", "- print(\"No\")", "+def main():", "+ N, D = map(int, input().split())", "+ xy = [tuple(map(int, input().split())) for _ in range(N)]", "+ ts = TwoSAT(N)", "+ for i in range(N - 1):", "+ for j in range(i + 1, N):", "+ for k1, k2 in [(0, 0), (0, 1), (1, 0), (1, 1)]:", "+ pos1, pos2 = xy[i][k1], xy[j][k2]", "+ if abs(pos2 - pos1) < D:", "+ ts.add_clause(i, k1 ^ 1, j, k2 ^ 1)", "+ if ts.satisfiable():", "+ print(\"Yes\")", "+ print(*[xy[i][ts.ans[i]] for i in range(N)], sep=\"\\n\")", "+ else:", "+ print(\"No\")", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.075357
0.074314
1.014044
[ "s826279144", "s134486990" ]
u219417113
p03103
python
s634621788
s125534089
875
247
59,992
17,732
Accepted
Accepted
71.77
N, M = list(map(int, input().split())) AB = sorted([tuple(map(int, input().split())) for _ in range(N)]) count = 0 ans = 0 for a, b in AB: if count + b >= M: ans += a * (M - count) break else: ans += a * b count += b print(ans)
def main(): import sys input = sys.stdin.readline N, M = list(map(int, input().split())) AB = sorted([tuple(map(int, input().split())) for _ in range(N)]) money = 0 count = 0 for a, b in AB: if count + b >= M: money += a * (M - count) break else: money += a * b count += b print(money) if __name__ == '__main__': main()
12
19
272
433
N, M = list(map(int, input().split())) AB = sorted([tuple(map(int, input().split())) for _ in range(N)]) count = 0 ans = 0 for a, b in AB: if count + b >= M: ans += a * (M - count) break else: ans += a * b count += b print(ans)
def main(): import sys input = sys.stdin.readline N, M = list(map(int, input().split())) AB = sorted([tuple(map(int, input().split())) for _ in range(N)]) money = 0 count = 0 for a, b in AB: if count + b >= M: money += a * (M - count) break else: money += a * b count += b print(money) if __name__ == "__main__": main()
false
36.842105
[ "-N, M = list(map(int, input().split()))", "-AB = sorted([tuple(map(int, input().split())) for _ in range(N)])", "-count = 0", "-ans = 0", "-for a, b in AB:", "- if count + b >= M:", "- ans += a * (M - count)", "- break", "- else:", "- ans += a * b", "- count += b", "-print(ans)", "+def main():", "+ import sys", "+", "+ input = sys.stdin.readline", "+ N, M = list(map(int, input().split()))", "+ AB = sorted([tuple(map(int, input().split())) for _ in range(N)])", "+ money = 0", "+ count = 0", "+ for a, b in AB:", "+ if count + b >= M:", "+ money += a * (M - count)", "+ break", "+ else:", "+ money += a * b", "+ count += b", "+ print(money)", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.044496
0.036125
1.231737
[ "s634621788", "s125534089" ]
u058240079
p03607
python
s942394498
s180117593
182
159
18,536
18,536
Accepted
Accepted
12.64
from collections import Counter c = Counter([int(input()) for _ in range(int(input()))]) print(len([x for x in list(c.values()) if x % 2 == 1]))
from collections import Counter print(len([x for x in list(Counter([int(input()) for _ in range(int(input()))]).values()) if x % 2 == 1]))
3
2
151
144
from collections import Counter c = Counter([int(input()) for _ in range(int(input()))]) print(len([x for x in list(c.values()) if x % 2 == 1]))
from collections import Counter print( len( [ x for x in list(Counter([int(input()) for _ in range(int(input()))]).values()) if x % 2 == 1 ] ) )
false
33.333333
[ "-c = Counter([int(input()) for _ in range(int(input()))])", "-print(len([x for x in list(c.values()) if x % 2 == 1]))", "+print(", "+ len(", "+ [", "+ x", "+ for x in list(Counter([int(input()) for _ in range(int(input()))]).values())", "+ if x % 2 == 1", "+ ]", "+ )", "+)" ]
false
0.039625
0.03942
1.005212
[ "s942394498", "s180117593" ]
u186838327
p02937
python
s716492078
s052070634
159
120
9,296
87,988
Accepted
Accepted
24.53
S = list(str(eval(input()))) T = list(str(eval(input()))) S_ = set(list(S)) T_ = set(list(T)) for c in T: if c not in S_: print((-1)) exit() d = [[] for _ in range(26)] for i, s in enumerate(S): d[ord(s)-ord('a')].append(i) #print(d) q = 0 pre = -1 import bisect for t in T: j = ord(t)-ord('a') idx = bisect.bisect_right(d[j], pre) if idx == len(d[j]): q += 1 pre = d[j][0] else: pre = d[j][idx] print((q*len(S)+pre+1))
s = list(str(eval(input()))) t = list(str(eval(input()))) X = [[] for _ in range(26)] for i, c in enumerate(s): j = ord(c)-ord('a') X[j].append(i) n = len(s) q = 0 r = -1 import bisect for c in t: j = ord(c)-ord('a') if len(X[j]) == 0: print((-1)) exit() idx = bisect.bisect_right(X[j], r) #print(X[j], idx) if idx == len(X[j]): q += 1 r = X[j][0] else: r = X[j][idx] #print(q, r) ans = q*n + r+1 print(ans)
27
27
497
498
S = list(str(eval(input()))) T = list(str(eval(input()))) S_ = set(list(S)) T_ = set(list(T)) for c in T: if c not in S_: print((-1)) exit() d = [[] for _ in range(26)] for i, s in enumerate(S): d[ord(s) - ord("a")].append(i) # print(d) q = 0 pre = -1 import bisect for t in T: j = ord(t) - ord("a") idx = bisect.bisect_right(d[j], pre) if idx == len(d[j]): q += 1 pre = d[j][0] else: pre = d[j][idx] print((q * len(S) + pre + 1))
s = list(str(eval(input()))) t = list(str(eval(input()))) X = [[] for _ in range(26)] for i, c in enumerate(s): j = ord(c) - ord("a") X[j].append(i) n = len(s) q = 0 r = -1 import bisect for c in t: j = ord(c) - ord("a") if len(X[j]) == 0: print((-1)) exit() idx = bisect.bisect_right(X[j], r) # print(X[j], idx) if idx == len(X[j]): q += 1 r = X[j][0] else: r = X[j][idx] # print(q, r) ans = q * n + r + 1 print(ans)
false
0
[ "-S = list(str(eval(input())))", "-T = list(str(eval(input())))", "-S_ = set(list(S))", "-T_ = set(list(T))", "-for c in T:", "- if c not in S_:", "+s = list(str(eval(input())))", "+t = list(str(eval(input())))", "+X = [[] for _ in range(26)]", "+for i, c in enumerate(s):", "+ j = ord(c) - ord(\"a\")", "+ X[j].append(i)", "+n = len(s)", "+q = 0", "+r = -1", "+import bisect", "+", "+for c in t:", "+ j = ord(c) - ord(\"a\")", "+ if len(X[j]) == 0:", "-d = [[] for _ in range(26)]", "-for i, s in enumerate(S):", "- d[ord(s) - ord(\"a\")].append(i)", "-# print(d)", "-q = 0", "-pre = -1", "-import bisect", "-", "-for t in T:", "- j = ord(t) - ord(\"a\")", "- idx = bisect.bisect_right(d[j], pre)", "- if idx == len(d[j]):", "+ idx = bisect.bisect_right(X[j], r)", "+ # print(X[j], idx)", "+ if idx == len(X[j]):", "- pre = d[j][0]", "+ r = X[j][0]", "- pre = d[j][idx]", "-print((q * len(S) + pre + 1))", "+ r = X[j][idx]", "+ # print(q, r)", "+ans = q * n + r + 1", "+print(ans)" ]
false
0.039655
0.047505
0.83476
[ "s716492078", "s052070634" ]
u562935282
p03019
python
s376043264
s603921728
859
613
81,820
79,708
Accepted
Accepted
28.64
# 解説 def accumulate(a): su = 0 yield su for x in a: su += x yield su def solve_agc034c(): from collections import namedtuple import sys input = sys.stdin.readline Test = namedtuple('Test', 'Aoki_score lower_bound upper_bound') Test.D_partial = lambda self, score: \ self.lower_bound * score if score <= self.Aoki_score \ else self.upper_bound * score - (self.upper_bound - self.lower_bound) * self.Aoki_score def is_ok(init_rest): """init_rest: 勉強に使える時間""" take, rest = divmod(init_rest, X) if take > N - 1: r = take - (N - 1) take = N - 1 rest += r * X for i, partial_solve_test in enumerate(tests, start=1): when_full = partial_solve_test.D_partial(X) if i <= take: su = acc[take + 1] - when_full else: su = acc[take] when_partial = partial_solve_test.D_partial(min(X, rest)) d = INIT_D + su + when_partial if d >= 0: return True return False def binary_search(*, ok, ng, is_ok): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok N, X = map(int, input().split()) tests = [] for _ in range(N): row = map(int, input().split()) tests.append(Test(*row)) tests.sort(key=lambda test: test.D_partial(X), reverse=True) # 勝つ科目と負ける科目を決める # 勝つ科目は重要度をupper_boundにする # 負ける科目は重要度をlower_boundにする INIT_D = -sum(test.lower_bound * test.Aoki_score for test in tests) *acc, = accumulate(test.D_partial(X) for test in tests) res = binary_search(ok=10 ** 10, ng=-1, is_ok=is_ok) # D>=0となる勉強時間 print(res) return if __name__ == '__main__': solve_agc034c()
# 写経 # にぶたん不要の解法 # https://atcoder.jp/contests/agc034/submissions/5768266 # generatorを作って # 外でminする def accumulate(a): """初項0""" su = 0 yield su for x in a: su += x yield su # class TestCaseReader: # def __init__(self): # self._gen = self.gen() # # def gen(self): # import os # folder = r'XXX' # with open(os.path.join(folder, 'in.txt'), mode='r') as f: # for row in f: # row = row.rstrip() # yield row # # def __call__(self): # return next(self._gen) def solve_agc034c(): from bisect import bisect_left from collections import namedtuple import sys input = sys.stdin.readline # input = TestCaseReader() Test = namedtuple('Test', 'Aoki_score lower_bound upper_bound') Test.Merit = lambda self, Takahashi_score: \ self.lower_bound * Takahashi_score if Takahashi_score <= self.Aoki_score \ else self.upper_bound * Takahashi_score - (self.upper_bound - self.lower_bound) * self.Aoki_score N, X = map(int, input().split()) tests = [] for _ in range(N): row = map(int, input().split()) tests.append(Test(*row)) tests.sort(key=lambda test: test.Merit(Takahashi_score=X), reverse=True) # 勝つ科目は重要度upper_bound,負ける科目は重要度lower_bound need = sum(test.lower_bound * test.Aoki_score for test in tests) *acc, = accumulate(test.Merit(Takahashi_score=X) for test in tests) bi = bisect_left(acc, need) # bi問目まで完答でneed以上を達成(bi:1-indexed)=bi問解けばよい if bi == 0: print(0) # 追加した return ge_need = acc[bi] # need以上を達成するのに要した点数 lt_need = acc[bi - 1] # need未満の最大値を達成するのに要した点数 def generate_candidates(): INF = 10 ** 20 for i, p in enumerate(tests, start=1): # p: partially_solved_test if i < bi: rest = need - (ge_need - p.Merit(Takahashi_score=X)) else: rest = need - lt_need if rest <= p.Merit(Takahashi_score=p.Aoki_score): # 科目p単体の所要点数はAoki君以下でよく,lower_boundで計算 add_ = (rest + p.lower_bound - 1) // p.lower_bound else: # 科目p単体の所要点数はAoki君を超える必要があり,upper_boundで計算 add_ = p.Aoki_score add_ += (rest - p.Merit(Takahashi_score=p.Aoki_score) + p.upper_bound - 1) // p.upper_bound if add_ > X: yield INF else: ret = X * (bi - 1) + add_ yield ret gen = generate_candidates() res = min(gen) print(res) return if __name__ == '__main__': solve_agc034c()
74
96
1,996
2,772
# 解説 def accumulate(a): su = 0 yield su for x in a: su += x yield su def solve_agc034c(): from collections import namedtuple import sys input = sys.stdin.readline Test = namedtuple("Test", "Aoki_score lower_bound upper_bound") Test.D_partial = ( lambda self, score: self.lower_bound * score if score <= self.Aoki_score else self.upper_bound * score - (self.upper_bound - self.lower_bound) * self.Aoki_score ) def is_ok(init_rest): """init_rest: 勉強に使える時間""" take, rest = divmod(init_rest, X) if take > N - 1: r = take - (N - 1) take = N - 1 rest += r * X for i, partial_solve_test in enumerate(tests, start=1): when_full = partial_solve_test.D_partial(X) if i <= take: su = acc[take + 1] - when_full else: su = acc[take] when_partial = partial_solve_test.D_partial(min(X, rest)) d = INIT_D + su + when_partial if d >= 0: return True return False def binary_search(*, ok, ng, is_ok): while abs(ok - ng) > 1: mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok N, X = map(int, input().split()) tests = [] for _ in range(N): row = map(int, input().split()) tests.append(Test(*row)) tests.sort(key=lambda test: test.D_partial(X), reverse=True) # 勝つ科目と負ける科目を決める # 勝つ科目は重要度をupper_boundにする # 負ける科目は重要度をlower_boundにする INIT_D = -sum(test.lower_bound * test.Aoki_score for test in tests) (*acc,) = accumulate(test.D_partial(X) for test in tests) res = binary_search(ok=10**10, ng=-1, is_ok=is_ok) # D>=0となる勉強時間 print(res) return if __name__ == "__main__": solve_agc034c()
# 写経 # にぶたん不要の解法 # https://atcoder.jp/contests/agc034/submissions/5768266 # generatorを作って # 外でminする def accumulate(a): """初項0""" su = 0 yield su for x in a: su += x yield su # class TestCaseReader: # def __init__(self): # self._gen = self.gen() # # def gen(self): # import os # folder = r'XXX' # with open(os.path.join(folder, 'in.txt'), mode='r') as f: # for row in f: # row = row.rstrip() # yield row # # def __call__(self): # return next(self._gen) def solve_agc034c(): from bisect import bisect_left from collections import namedtuple import sys input = sys.stdin.readline # input = TestCaseReader() Test = namedtuple("Test", "Aoki_score lower_bound upper_bound") Test.Merit = ( lambda self, Takahashi_score: self.lower_bound * Takahashi_score if Takahashi_score <= self.Aoki_score else self.upper_bound * Takahashi_score - (self.upper_bound - self.lower_bound) * self.Aoki_score ) N, X = map(int, input().split()) tests = [] for _ in range(N): row = map(int, input().split()) tests.append(Test(*row)) tests.sort(key=lambda test: test.Merit(Takahashi_score=X), reverse=True) # 勝つ科目は重要度upper_bound,負ける科目は重要度lower_bound need = sum(test.lower_bound * test.Aoki_score for test in tests) (*acc,) = accumulate(test.Merit(Takahashi_score=X) for test in tests) bi = bisect_left(acc, need) # bi問目まで完答でneed以上を達成(bi:1-indexed)=bi問解けばよい if bi == 0: print(0) # 追加した return ge_need = acc[bi] # need以上を達成するのに要した点数 lt_need = acc[bi - 1] # need未満の最大値を達成するのに要した点数 def generate_candidates(): INF = 10**20 for i, p in enumerate(tests, start=1): # p: partially_solved_test if i < bi: rest = need - (ge_need - p.Merit(Takahashi_score=X)) else: rest = need - lt_need if rest <= p.Merit(Takahashi_score=p.Aoki_score): # 科目p単体の所要点数はAoki君以下でよく,lower_boundで計算 add_ = (rest + p.lower_bound - 1) // p.lower_bound else: # 科目p単体の所要点数はAoki君を超える必要があり,upper_boundで計算 add_ = p.Aoki_score add_ += ( rest - p.Merit(Takahashi_score=p.Aoki_score) + p.upper_bound - 1 ) // p.upper_bound if add_ > X: yield INF else: ret = X * (bi - 1) + add_ yield ret gen = generate_candidates() res = min(gen) print(res) return if __name__ == "__main__": solve_agc034c()
false
22.916667
[ "-# 解説", "+# 写経", "+# にぶたん不要の解法", "+# https://atcoder.jp/contests/agc034/submissions/5768266", "+# generatorを作って", "+# 外でminする", "+ \"\"\"初項0\"\"\"", "+# class TestCaseReader:", "+# def __init__(self):", "+# self._gen = self.gen()", "+#", "+# def gen(self):", "+# import os", "+# folder = r'XXX'", "+# with open(os.path.join(folder, 'in.txt'), mode='r') as f:", "+# for row in f:", "+# row = row.rstrip()", "+# yield row", "+#", "+# def __call__(self):", "+# return next(self._gen)", "+ from bisect import bisect_left", "+ # input = TestCaseReader()", "- Test.D_partial = (", "- lambda self, score: self.lower_bound * score", "- if score <= self.Aoki_score", "- else self.upper_bound * score", "+ Test.Merit = (", "+ lambda self, Takahashi_score: self.lower_bound * Takahashi_score", "+ if Takahashi_score <= self.Aoki_score", "+ else self.upper_bound * Takahashi_score", "-", "- def is_ok(init_rest):", "- \"\"\"init_rest: 勉強に使える時間\"\"\"", "- take, rest = divmod(init_rest, X)", "- if take > N - 1:", "- r = take - (N - 1)", "- take = N - 1", "- rest += r * X", "- for i, partial_solve_test in enumerate(tests, start=1):", "- when_full = partial_solve_test.D_partial(X)", "- if i <= take:", "- su = acc[take + 1] - when_full", "- else:", "- su = acc[take]", "- when_partial = partial_solve_test.D_partial(min(X, rest))", "- d = INIT_D + su + when_partial", "- if d >= 0:", "- return True", "- return False", "-", "- def binary_search(*, ok, ng, is_ok):", "- while abs(ok - ng) > 1:", "- mid = (ok + ng) // 2", "- if is_ok(mid):", "- ok = mid", "- else:", "- ng = mid", "- return ok", "-", "- tests.sort(key=lambda test: test.D_partial(X), reverse=True)", "- # 勝つ科目と負ける科目を決める", "- # 勝つ科目は重要度をupper_boundにする", "- # 負ける科目は重要度をlower_boundにする", "- INIT_D = -sum(test.lower_bound * test.Aoki_score for test in tests)", "- (*acc,) = accumulate(test.D_partial(X) for test in tests)", "- res = binary_search(ok=10**10, ng=-1, is_ok=is_ok)", "- # D>=0となる勉強時間", "+ tests.sort(key=lambda test: test.Merit(Takahashi_score=X), reverse=True)", "+ # 勝つ科目は重要度upper_bound,負ける科目は重要度lower_bound", "+ need = sum(test.lower_bound * test.Aoki_score for test in tests)", "+ (*acc,) = accumulate(test.Merit(Takahashi_score=X) for test in tests)", "+ bi = bisect_left(acc, need) # bi問目まで完答でneed以上を達成(bi:1-indexed)=bi問解けばよい", "+ if bi == 0:", "+ print(0) # 追加した", "+ return", "+ ge_need = acc[bi] # need以上を達成するのに要した点数", "+ lt_need = acc[bi - 1] # need未満の最大値を達成するのに要した点数", "+", "+ def generate_candidates():", "+ INF = 10**20", "+ for i, p in enumerate(tests, start=1):", "+ # p: partially_solved_test", "+ if i < bi:", "+ rest = need - (ge_need - p.Merit(Takahashi_score=X))", "+ else:", "+ rest = need - lt_need", "+ if rest <= p.Merit(Takahashi_score=p.Aoki_score):", "+ # 科目p単体の所要点数はAoki君以下でよく,lower_boundで計算", "+ add_ = (rest + p.lower_bound - 1) // p.lower_bound", "+ else:", "+ # 科目p単体の所要点数はAoki君を超える必要があり,upper_boundで計算", "+ add_ = p.Aoki_score", "+ add_ += (", "+ rest - p.Merit(Takahashi_score=p.Aoki_score) + p.upper_bound - 1", "+ ) // p.upper_bound", "+ if add_ > X:", "+ yield INF", "+ else:", "+ ret = X * (bi - 1) + add_", "+ yield ret", "+", "+ gen = generate_candidates()", "+ res = min(gen)" ]
false
0.140496
0.036397
3.860152
[ "s376043264", "s603921728" ]
u347640436
p02639
python
s771452929
s372014741
26
24
9,016
8,676
Accepted
Accepted
7.69
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i + 1)) exit()
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i + 1)) break
6
6
115
114
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i + 1)) exit()
x = list(map(int, input().split())) for i in range(5): if x[i] == 0: print((i + 1)) break
false
0
[ "- exit()", "+ break" ]
false
0.048742
0.128892
0.378162
[ "s771452929", "s372014741" ]
u192042624
p02691
python
s881056221
s560649744
559
440
112,988
95,452
Accepted
Accepted
21.29
import numpy as np import sys import math import collections read = sys.stdin.readline N = int(read().rstrip()) A = list(map(int,read().rstrip().split())) da = [] for i , a in enumerate(A): da.append([i,a]) dR = collections.defaultdict(int) dL = collections.defaultdict(int) ans = 0 for d in reversed(da): r = d[0] + d[1] + 1 l = d[0] - d[1] + 1 dR[r] += 1 ans += dL[r] dL[l] += 1 print(ans)
import numpy as np import sys import math read = sys.stdin.readline N = int(read().rstrip()) A = list(map(int,read().rstrip().split())) da = [] for i , a in enumerate(A): da.append([i,a]) dR = {} dL = {} ans = 0 for d in reversed(da): r = d[0] + d[1] + 1 l = d[0] - d[1] + 1 if r in dR: dR[r] += 1 else: dR[r] = 1 if r in dL: ans += dL[r] if l in dL : dL[l] += 1 else: dL[l] = 1 print(ans)
27
32
451
502
import numpy as np import sys import math import collections read = sys.stdin.readline N = int(read().rstrip()) A = list(map(int, read().rstrip().split())) da = [] for i, a in enumerate(A): da.append([i, a]) dR = collections.defaultdict(int) dL = collections.defaultdict(int) ans = 0 for d in reversed(da): r = d[0] + d[1] + 1 l = d[0] - d[1] + 1 dR[r] += 1 ans += dL[r] dL[l] += 1 print(ans)
import numpy as np import sys import math read = sys.stdin.readline N = int(read().rstrip()) A = list(map(int, read().rstrip().split())) da = [] for i, a in enumerate(A): da.append([i, a]) dR = {} dL = {} ans = 0 for d in reversed(da): r = d[0] + d[1] + 1 l = d[0] - d[1] + 1 if r in dR: dR[r] += 1 else: dR[r] = 1 if r in dL: ans += dL[r] if l in dL: dL[l] += 1 else: dL[l] = 1 print(ans)
false
15.625
[ "-import collections", "-dR = collections.defaultdict(int)", "-dL = collections.defaultdict(int)", "+dR = {}", "+dL = {}", "- dR[r] += 1", "- ans += dL[r]", "- dL[l] += 1", "+ if r in dR:", "+ dR[r] += 1", "+ else:", "+ dR[r] = 1", "+ if r in dL:", "+ ans += dL[r]", "+ if l in dL:", "+ dL[l] += 1", "+ else:", "+ dL[l] = 1" ]
false
0.047508
0.045736
1.038745
[ "s881056221", "s560649744" ]
u790710233
p03474
python
s181472724
s112586920
19
17
3,060
2,940
Accepted
Accepted
10.53
a, b = list(map(int, input().split())) s = eval(input()) print(('Yes' if len(s) == a + b + 1 and s[a] == '-' and all(i in '0123456789' for i in s[:a]+s[a+1:]) else 'No'))
a, b = list(map(int, input().split())) s = eval(input()) print(('Yes' if s.count('-') == 1 and s[a] == '-' else 'No'))
4
3
166
107
a, b = list(map(int, input().split())) s = eval(input()) print( ( "Yes" if len(s) == a + b + 1 and s[a] == "-" and all(i in "0123456789" for i in s[:a] + s[a + 1 :]) else "No" ) )
a, b = list(map(int, input().split())) s = eval(input()) print(("Yes" if s.count("-") == 1 and s[a] == "-" else "No"))
false
25
[ "-print(", "- (", "- \"Yes\"", "- if len(s) == a + b + 1", "- and s[a] == \"-\"", "- and all(i in \"0123456789\" for i in s[:a] + s[a + 1 :])", "- else \"No\"", "- )", "-)", "+print((\"Yes\" if s.count(\"-\") == 1 and s[a] == \"-\" else \"No\"))" ]
false
0.044833
0.045832
0.978216
[ "s181472724", "s112586920" ]
u971091945
p02614
python
s047411810
s959262410
143
65
9,252
9,176
Accepted
Accepted
54.55
import copy h, w, k = list(map(int, input().split())) hw = [] mas = [] mas_su = 0 for i in range(h): hwi = eval(input()) masi = [] for j in range(w): if hwi[j] == "#": masi.append(1) else: masi.append(0) mas_su += sum(masi) mas.append(masi) l = 2**(h+w) ans = 0 for i in range(l): test = copy.deepcopy(mas) num = 0 for j in range(h+w): if ((i >> j) & 1): if j < h: for p in range(w): if test[j][p]==1: test[j][p] = 0 num += 1 else: for p in range(h): if test[p][j-h]==1: test[p][j-h] = 0 num += 1 if mas_su-num == k: ans += 1 print(ans)
h, w, k = [int(i) for i in input().split()] mas = [eval(input()) for _ in range(h)] ans = 0 for h_1 in range(2**h): for w_1 in range(2**w): black = 0 for i in range(h): for j in range(w): if (h_1 >> i) & 1 == 0 and (w_1 >> j) & 1 == 0 and mas[i][j] == '#': black += 1 if black == k: ans += 1 print(ans)
40
16
852
402
import copy h, w, k = list(map(int, input().split())) hw = [] mas = [] mas_su = 0 for i in range(h): hwi = eval(input()) masi = [] for j in range(w): if hwi[j] == "#": masi.append(1) else: masi.append(0) mas_su += sum(masi) mas.append(masi) l = 2 ** (h + w) ans = 0 for i in range(l): test = copy.deepcopy(mas) num = 0 for j in range(h + w): if (i >> j) & 1: if j < h: for p in range(w): if test[j][p] == 1: test[j][p] = 0 num += 1 else: for p in range(h): if test[p][j - h] == 1: test[p][j - h] = 0 num += 1 if mas_su - num == k: ans += 1 print(ans)
h, w, k = [int(i) for i in input().split()] mas = [eval(input()) for _ in range(h)] ans = 0 for h_1 in range(2**h): for w_1 in range(2**w): black = 0 for i in range(h): for j in range(w): if (h_1 >> i) & 1 == 0 and (w_1 >> j) & 1 == 0 and mas[i][j] == "#": black += 1 if black == k: ans += 1 print(ans)
false
60
[ "-import copy", "-", "-h, w, k = list(map(int, input().split()))", "-hw = []", "-mas = []", "-mas_su = 0", "-for i in range(h):", "- hwi = eval(input())", "- masi = []", "- for j in range(w):", "- if hwi[j] == \"#\":", "- masi.append(1)", "- else:", "- masi.append(0)", "- mas_su += sum(masi)", "- mas.append(masi)", "-l = 2 ** (h + w)", "+h, w, k = [int(i) for i in input().split()]", "+mas = [eval(input()) for _ in range(h)]", "-for i in range(l):", "- test = copy.deepcopy(mas)", "- num = 0", "- for j in range(h + w):", "- if (i >> j) & 1:", "- if j < h:", "- for p in range(w):", "- if test[j][p] == 1:", "- test[j][p] = 0", "- num += 1", "- else:", "- for p in range(h):", "- if test[p][j - h] == 1:", "- test[p][j - h] = 0", "- num += 1", "- if mas_su - num == k:", "- ans += 1", "+for h_1 in range(2**h):", "+ for w_1 in range(2**w):", "+ black = 0", "+ for i in range(h):", "+ for j in range(w):", "+ if (h_1 >> i) & 1 == 0 and (w_1 >> j) & 1 == 0 and mas[i][j] == \"#\":", "+ black += 1", "+ if black == k:", "+ ans += 1" ]
false
0.093934
0.048125
1.951884
[ "s047411810", "s959262410" ]
u888337853
p03295
python
s983211849
s418915446
220
175
26,068
25,956
Accepted
Accepted
20.45
import sys import math import collections import bisect import copy # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 16 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda: list(map(int, sys.stdin.readline().split())) na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()]) # ===CODE=== def main(): n, m = ns() d = [] for _ in range(m): a, b = ns() d.append([a - 1, b - 1]) d.sort(key=lambda x: x[1]) down = [] for a, b in d: idx = bisect.bisect_left(down, a) if idx == len(down): down.append(b - 1) print((len(down))) if __name__ == '__main__': main()
import sys import math import collections import bisect import copy # import numpy as np sys.setrecursionlimit(10 ** 7) INF = 10 ** 16 MOD = 10 ** 9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda: list(map(int, sys.stdin.readline().split())) na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()]) # ===CODE=== def main(): n, m = ns() d = [] for _ in range(m): a, b = ns() d.append([a - 1, b - 1]) d.sort(key=lambda x: x[1]) down = -1 ans = 0 for a, b in d: if down < a: down = b-1 ans += 1 print(ans) if __name__ == '__main__': main()
42
42
802
770
import sys import math import collections import bisect import copy # import numpy as np sys.setrecursionlimit(10**7) INF = 10**16 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda: list(map(int, sys.stdin.readline().split())) na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()]) # ===CODE=== def main(): n, m = ns() d = [] for _ in range(m): a, b = ns() d.append([a - 1, b - 1]) d.sort(key=lambda x: x[1]) down = [] for a, b in d: idx = bisect.bisect_left(down, a) if idx == len(down): down.append(b - 1) print((len(down))) if __name__ == "__main__": main()
import sys import math import collections import bisect import copy # import numpy as np sys.setrecursionlimit(10**7) INF = 10**16 MOD = 10**9 + 7 # MOD = 998244353 ni = lambda: int(sys.stdin.readline()) ns = lambda: list(map(int, sys.stdin.readline().split())) na = lambda: list(map(int, sys.stdin.readline().split())) na1 = lambda: list([int(x) - 1 for x in sys.stdin.readline().split()]) # ===CODE=== def main(): n, m = ns() d = [] for _ in range(m): a, b = ns() d.append([a - 1, b - 1]) d.sort(key=lambda x: x[1]) down = -1 ans = 0 for a, b in d: if down < a: down = b - 1 ans += 1 print(ans) if __name__ == "__main__": main()
false
0
[ "- down = []", "+ down = -1", "+ ans = 0", "- idx = bisect.bisect_left(down, a)", "- if idx == len(down):", "- down.append(b - 1)", "- print((len(down)))", "+ if down < a:", "+ down = b - 1", "+ ans += 1", "+ print(ans)" ]
false
0.070767
0.038341
1.845734
[ "s983211849", "s418915446" ]
u131984977
p02412
python
s721700065
s243223479
900
590
6,720
6,720
Accepted
Accepted
34.44
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break count = 0 limit = n if n < x else x for a in range(1, limit + 1): for b in range(a + 1, limit + 1): for c in range(b + 1, limit + 1): if sum([a,b,c]) == x: count += 1 print(count)
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break count = 0 start = n if n < x else x for a in range(start, 0, -1): if a >= x: continue for b in range(a - 1, 0, -1): if sum([a,b]) >= x: continue for c in range(b - 1, 0, -1): if sum([a,b,c]) == x: count += 1 print(count)
14
17
359
450
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break count = 0 limit = n if n < x else x for a in range(1, limit + 1): for b in range(a + 1, limit + 1): for c in range(b + 1, limit + 1): if sum([a, b, c]) == x: count += 1 print(count)
while True: (n, x) = [int(i) for i in input().split()] if n == x == 0: break count = 0 start = n if n < x else x for a in range(start, 0, -1): if a >= x: continue for b in range(a - 1, 0, -1): if sum([a, b]) >= x: continue for c in range(b - 1, 0, -1): if sum([a, b, c]) == x: count += 1 print(count)
false
17.647059
[ "- limit = n if n < x else x", "- for a in range(1, limit + 1):", "- for b in range(a + 1, limit + 1):", "- for c in range(b + 1, limit + 1):", "+ start = n if n < x else x", "+ for a in range(start, 0, -1):", "+ if a >= x:", "+ continue", "+ for b in range(a - 1, 0, -1):", "+ if sum([a, b]) >= x:", "+ continue", "+ for c in range(b - 1, 0, -1):" ]
false
0.064225
0.114386
0.561477
[ "s721700065", "s243223479" ]
u867848444
p02659
python
s728746844
s328015307
23
20
9,108
9,108
Accepted
Accepted
13.04
a, b = list(map(float, input().split())) a = int(a) b = int(b * 100 + 0.5) ans = a * b // 100 print((int(ans)))
a, b = list(map(float, input().split())) a = int(a) b = int(b * 1000) ans = a * b // 1000 print((int(ans)))
5
5
107
103
a, b = list(map(float, input().split())) a = int(a) b = int(b * 100 + 0.5) ans = a * b // 100 print((int(ans)))
a, b = list(map(float, input().split())) a = int(a) b = int(b * 1000) ans = a * b // 1000 print((int(ans)))
false
0
[ "-b = int(b * 100 + 0.5)", "-ans = a * b // 100", "+b = int(b * 1000)", "+ans = a * b // 1000" ]
false
0.039119
0.04768
0.820462
[ "s728746844", "s328015307" ]
u766566560
p03370
python
s348906225
s893590587
28
17
2,940
2,940
Accepted
Accepted
39.29
N, X = list(map(int, input().split())) list = [] for i in range(N): m = int(eval(input())) list.append(m) print((N + (X - sum(list)) // min(list)))
N, X = list(map(int, input().split())) m = [int(eval(input())) for _ in range(N)] print((N + (X - sum(m)) // min(m)))
7
3
146
107
N, X = list(map(int, input().split())) list = [] for i in range(N): m = int(eval(input())) list.append(m) print((N + (X - sum(list)) // min(list)))
N, X = list(map(int, input().split())) m = [int(eval(input())) for _ in range(N)] print((N + (X - sum(m)) // min(m)))
false
57.142857
[ "-list = []", "-for i in range(N):", "- m = int(eval(input()))", "- list.append(m)", "-print((N + (X - sum(list)) // min(list)))", "+m = [int(eval(input())) for _ in range(N)]", "+print((N + (X - sum(m)) // min(m)))" ]
false
0.041593
0.056381
0.737709
[ "s348906225", "s893590587" ]
u982591663
p02779
python
s495871701
s987211150
179
116
26,808
32,948
Accepted
Accepted
35.2
#C N = int(eval(input())) A = sorted(list(map(int, input().split()))) ans = "YES" for i in range(N-1): if A[i] == A[i+1]: ans = "NO" break print(ans)
N = int(eval(input())) A = list(map(int, input().split())) memo = {} ans = "YES" for a in A: if a in memo: ans = "NO" break memo[a] = None print(ans)
11
12
183
181
# C N = int(eval(input())) A = sorted(list(map(int, input().split()))) ans = "YES" for i in range(N - 1): if A[i] == A[i + 1]: ans = "NO" break print(ans)
N = int(eval(input())) A = list(map(int, input().split())) memo = {} ans = "YES" for a in A: if a in memo: ans = "NO" break memo[a] = None print(ans)
false
8.333333
[ "-# C", "-A = sorted(list(map(int, input().split())))", "+A = list(map(int, input().split()))", "+memo = {}", "-for i in range(N - 1):", "- if A[i] == A[i + 1]:", "+for a in A:", "+ if a in memo:", "+ memo[a] = None" ]
false
0.036447
0.043905
0.830133
[ "s495871701", "s987211150" ]
u316341119
p03045
python
s111312862
s088750805
1,547
711
84,832
53,664
Accepted
Accepted
54.04
from queue import Queue N, M = list(map(int, input().split())) d = {} for i in range(1, N+1): d[i] = [] for i in range(M): x, y, z = list(map(int, input().split())) d[x].append(y) d[y].append(x) isChecked = [False for i in range(N)] ans = 0 for k in d: if isChecked[k-1]: continue ans += 1 q = Queue() q.put(k) while not q.empty(): v = q.get() if isChecked[v-1]: continue isChecked[v-1] = True for u in d[v]: q.put(u) print(ans)
class UnionFindTree: _node_num = 0 _parent_list = [] _tree_len = [] _num_trees = 0 def __init__(self, node_num): self._node_num = node_num self._parent_list = [-1 for i in range(node_num+1)] self._tree_len = [0 for i in range(node_num+1)] self._num_trees = node_num def _root(self, node): root = node while self._parent_list[root] != -1: root = self._parent_list[root] return root def union(self, x, y): xr = self._root(x) yr = self._root(y) if xr == yr: return if self._tree_len[xr] < self._tree_len[yr]: self._parent_list[xr] = yr self._tree_len[yr] += 1 else: self._parent_list[yr] = xr self._tree_len[xr] += 1 self._num_trees -= 1 def get_num_trees(self): return self._num_trees def main(): N, M = list(map(int, input().split())) uft = UnionFindTree(N) for i in range(M): x, y, z = list(map(int, input().split())) uft.union(x, y) print((uft.get_num_trees())) if __name__ == '__main__': main()
28
45
547
1,186
from queue import Queue N, M = list(map(int, input().split())) d = {} for i in range(1, N + 1): d[i] = [] for i in range(M): x, y, z = list(map(int, input().split())) d[x].append(y) d[y].append(x) isChecked = [False for i in range(N)] ans = 0 for k in d: if isChecked[k - 1]: continue ans += 1 q = Queue() q.put(k) while not q.empty(): v = q.get() if isChecked[v - 1]: continue isChecked[v - 1] = True for u in d[v]: q.put(u) print(ans)
class UnionFindTree: _node_num = 0 _parent_list = [] _tree_len = [] _num_trees = 0 def __init__(self, node_num): self._node_num = node_num self._parent_list = [-1 for i in range(node_num + 1)] self._tree_len = [0 for i in range(node_num + 1)] self._num_trees = node_num def _root(self, node): root = node while self._parent_list[root] != -1: root = self._parent_list[root] return root def union(self, x, y): xr = self._root(x) yr = self._root(y) if xr == yr: return if self._tree_len[xr] < self._tree_len[yr]: self._parent_list[xr] = yr self._tree_len[yr] += 1 else: self._parent_list[yr] = xr self._tree_len[xr] += 1 self._num_trees -= 1 def get_num_trees(self): return self._num_trees def main(): N, M = list(map(int, input().split())) uft = UnionFindTree(N) for i in range(M): x, y, z = list(map(int, input().split())) uft.union(x, y) print((uft.get_num_trees())) if __name__ == "__main__": main()
false
37.777778
[ "-from queue import Queue", "+class UnionFindTree:", "+ _node_num = 0", "+ _parent_list = []", "+ _tree_len = []", "+ _num_trees = 0", "-N, M = list(map(int, input().split()))", "-d = {}", "-for i in range(1, N + 1):", "- d[i] = []", "-for i in range(M):", "- x, y, z = list(map(int, input().split()))", "- d[x].append(y)", "- d[y].append(x)", "-isChecked = [False for i in range(N)]", "-ans = 0", "-for k in d:", "- if isChecked[k - 1]:", "- continue", "- ans += 1", "- q = Queue()", "- q.put(k)", "- while not q.empty():", "- v = q.get()", "- if isChecked[v - 1]:", "- continue", "- isChecked[v - 1] = True", "- for u in d[v]:", "- q.put(u)", "-print(ans)", "+ def __init__(self, node_num):", "+ self._node_num = node_num", "+ self._parent_list = [-1 for i in range(node_num + 1)]", "+ self._tree_len = [0 for i in range(node_num + 1)]", "+ self._num_trees = node_num", "+", "+ def _root(self, node):", "+ root = node", "+ while self._parent_list[root] != -1:", "+ root = self._parent_list[root]", "+ return root", "+", "+ def union(self, x, y):", "+ xr = self._root(x)", "+ yr = self._root(y)", "+ if xr == yr:", "+ return", "+ if self._tree_len[xr] < self._tree_len[yr]:", "+ self._parent_list[xr] = yr", "+ self._tree_len[yr] += 1", "+ else:", "+ self._parent_list[yr] = xr", "+ self._tree_len[xr] += 1", "+ self._num_trees -= 1", "+", "+ def get_num_trees(self):", "+ return self._num_trees", "+", "+", "+def main():", "+ N, M = list(map(int, input().split()))", "+ uft = UnionFindTree(N)", "+ for i in range(M):", "+ x, y, z = list(map(int, input().split()))", "+ uft.union(x, y)", "+ print((uft.get_num_trees()))", "+", "+", "+if __name__ == \"__main__\":", "+ main()" ]
false
0.2054
0.043885
4.68039
[ "s111312862", "s088750805" ]
u102461423
p04034
python
s910636477
s385087074
113
95
15,608
22,496
Accepted
Accepted
15.93
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N,M = list(map(int,readline().split())) m = list(map(int,read().split())) XY = list(zip(m,m)) red = [0] + [1] + [0] * (N-1) ball = [0] + [1] * N for x,y in XY: if red[x]: red[y] = 1 ball[x] -= 1; ball[y] += 1 if not ball[x]: red[x] = 0 answer = sum(red) print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = list(map(int, readline().split())) m = list(map(int, read().split())) count = [1] * (N+1) red = [0] * (N+1) red[1] = True for x, y in zip(m, m): count[x] -= 1 count[y] += 1 if red[x]: red[y] = 1 if not count[x]: red[x] = 0 print((sum(red)))
21
21
417
405
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = list(map(int, readline().split())) m = list(map(int, read().split())) XY = list(zip(m, m)) red = [0] + [1] + [0] * (N - 1) ball = [0] + [1] * N for x, y in XY: if red[x]: red[y] = 1 ball[x] -= 1 ball[y] += 1 if not ball[x]: red[x] = 0 answer = sum(red) print(answer)
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = list(map(int, readline().split())) m = list(map(int, read().split())) count = [1] * (N + 1) red = [0] * (N + 1) red[1] = True for x, y in zip(m, m): count[x] -= 1 count[y] += 1 if red[x]: red[y] = 1 if not count[x]: red[x] = 0 print((sum(red)))
false
0
[ "-XY = list(zip(m, m))", "-red = [0] + [1] + [0] * (N - 1)", "-ball = [0] + [1] * N", "-for x, y in XY:", "+count = [1] * (N + 1)", "+red = [0] * (N + 1)", "+red[1] = True", "+for x, y in zip(m, m):", "+ count[x] -= 1", "+ count[y] += 1", "- ball[x] -= 1", "- ball[y] += 1", "- if not ball[x]:", "+ if not count[x]:", "-answer = sum(red)", "-print(answer)", "+print((sum(red)))" ]
false
0.036519
0.067557
0.540571
[ "s910636477", "s385087074" ]
u940139461
p03575
python
s917118509
s088468555
238
188
43,484
40,560
Accepted
Accepted
21.01
n, m = list(map(int, input().split())) brides = [] for _ in range(m): a, b = list(map(int, input().split())) brides.append((a, b)) class Union: def __init__(self, val): self.val = val self.parent = self self.rank = 0 def get_root(self): n = self while n.parent != n: n = n.parent return n def find_set(self): return self.get_root().val ans = 0 for i in range(m): unions = [] for val in range(n): unions.append(Union(val)) for index, (a, b) in enumerate(brides): if i == index: continue x, y = unions[a - 1], unions[b - 1] x_root = x.get_root() y_root = y.get_root() if x_root.rank == y_root.rank: x_root.rank += 1 y_root.parent = x_root elif x_root.rank > y_root.rank: y_root.parent = x_root else: x_root.parent = y_root groups = [None] * n for j, u in enumerate(unions): root = u.find_set() groups[j] = root for g in range(1, n): if groups[g - 1] != groups[g]: ans += 1 break print(ans)
# https://atcoder.jp/contests/abc075/tasks/abc075_c # 各頂点を結ぶクエリー(a, bの情報)ごとに、 # それを実行しなくてもたどり着ける頂点が総頂点数(n)に一致するかを判定する。 n, m = list(map(int, input().split())) queries = [] for _ in range(m): a, b = list(map(int, input().split())) queries.append((a, b)) def dfs(graph, n): visited = [False] * (n + 1) visited[0] = True # 1-indexedなので、0番目は関係ない stack = [1] num = 0 while stack: t = stack.pop() for node in graph[t]: if visited[node]: continue visited[node] = True stack.append(node) num += 1 if num == n: return True return False ans = 0 for i in range(m): graph = [[] for _ in range(n + 1)] for j in range(m): if i == j: continue a, b = queries[j] graph[a].append(b) graph[b].append(a) if not dfs(graph, n): ans += 1 print(ans)
51
39
1,216
941
n, m = list(map(int, input().split())) brides = [] for _ in range(m): a, b = list(map(int, input().split())) brides.append((a, b)) class Union: def __init__(self, val): self.val = val self.parent = self self.rank = 0 def get_root(self): n = self while n.parent != n: n = n.parent return n def find_set(self): return self.get_root().val ans = 0 for i in range(m): unions = [] for val in range(n): unions.append(Union(val)) for index, (a, b) in enumerate(brides): if i == index: continue x, y = unions[a - 1], unions[b - 1] x_root = x.get_root() y_root = y.get_root() if x_root.rank == y_root.rank: x_root.rank += 1 y_root.parent = x_root elif x_root.rank > y_root.rank: y_root.parent = x_root else: x_root.parent = y_root groups = [None] * n for j, u in enumerate(unions): root = u.find_set() groups[j] = root for g in range(1, n): if groups[g - 1] != groups[g]: ans += 1 break print(ans)
# https://atcoder.jp/contests/abc075/tasks/abc075_c # 各頂点を結ぶクエリー(a, bの情報)ごとに、 # それを実行しなくてもたどり着ける頂点が総頂点数(n)に一致するかを判定する。 n, m = list(map(int, input().split())) queries = [] for _ in range(m): a, b = list(map(int, input().split())) queries.append((a, b)) def dfs(graph, n): visited = [False] * (n + 1) visited[0] = True # 1-indexedなので、0番目は関係ない stack = [1] num = 0 while stack: t = stack.pop() for node in graph[t]: if visited[node]: continue visited[node] = True stack.append(node) num += 1 if num == n: return True return False ans = 0 for i in range(m): graph = [[] for _ in range(n + 1)] for j in range(m): if i == j: continue a, b = queries[j] graph[a].append(b) graph[b].append(a) if not dfs(graph, n): ans += 1 print(ans)
false
23.529412
[ "+# https://atcoder.jp/contests/abc075/tasks/abc075_c", "+# 各頂点を結ぶクエリー(a, bの情報)ごとに、", "+# それを実行しなくてもたどり着ける頂点が総頂点数(n)に一致するかを判定する。", "-brides = []", "+queries = []", "- brides.append((a, b))", "+ queries.append((a, b))", "-class Union:", "- def __init__(self, val):", "- self.val = val", "- self.parent = self", "- self.rank = 0", "-", "- def get_root(self):", "- n = self", "- while n.parent != n:", "- n = n.parent", "- return n", "-", "- def find_set(self):", "- return self.get_root().val", "+def dfs(graph, n):", "+ visited = [False] * (n + 1)", "+ visited[0] = True # 1-indexedなので、0番目は関係ない", "+ stack = [1]", "+ num = 0", "+ while stack:", "+ t = stack.pop()", "+ for node in graph[t]:", "+ if visited[node]:", "+ continue", "+ visited[node] = True", "+ stack.append(node)", "+ num += 1", "+ if num == n:", "+ return True", "+ return False", "- unions = []", "- for val in range(n):", "- unions.append(Union(val))", "- for index, (a, b) in enumerate(brides):", "- if i == index:", "+ graph = [[] for _ in range(n + 1)]", "+ for j in range(m):", "+ if i == j:", "- x, y = unions[a - 1], unions[b - 1]", "- x_root = x.get_root()", "- y_root = y.get_root()", "- if x_root.rank == y_root.rank:", "- x_root.rank += 1", "- y_root.parent = x_root", "- elif x_root.rank > y_root.rank:", "- y_root.parent = x_root", "- else:", "- x_root.parent = y_root", "- groups = [None] * n", "- for j, u in enumerate(unions):", "- root = u.find_set()", "- groups[j] = root", "- for g in range(1, n):", "- if groups[g - 1] != groups[g]:", "- ans += 1", "- break", "+ a, b = queries[j]", "+ graph[a].append(b)", "+ graph[b].append(a)", "+ if not dfs(graph, n):", "+ ans += 1" ]
false
0.036
0.034858
1.032765
[ "s917118509", "s088468555" ]
u022407960
p02366
python
s856196268
s258108239
230
180
23,884
23,784
Accepted
Accepted
21.74
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 1 2 3 """ import sys sys.setrecursionlimit(int(1e6)) def generate_adj_table(_v_info): for v_detail in _v_info: source, target = map(int, v_detail) init_adj_table[source].append(target) init_adj_table[target].append(source) return init_adj_table def Tarjan(current, parents, visited, disc, low): global timer current_children_count = 0 visited[current] = True disc[current] = low[current] = timer timer += 1 for adj in adj_table[current]: if not visited[adj]: parents[adj] = current current_children_count += 1 Tarjan(adj, parents, visited, disc, low) low[current] = min(low[current], low[adj]) # current is root of DFS tree if parents[current] == -1 and current_children_count > 1: art_set.add(current) elif parents[current] != -1 and low[adj] >= disc[current]: art_set.add(current) elif adj != parents[current]: low[current] = min(low[current], disc[adj]) # print(timer, parents, visited, disc, low) return None def art_points(): parents = [-1] * vertices visited = [False] * vertices disc = [float('inf')] * vertices low = [float('inf')] * vertices for v in range(vertices): Tarjan(v, parents, visited, disc, low) return art_set if __name__ == '__main__': _input = sys.stdin.readlines() vertices, edges = map(int, _input[0].split()) v_info = map(lambda x: x.split(), _input[1:]) init_adj_table = tuple([] for _ in range(vertices)) adj_table = generate_adj_table(v_info) timer = 0 art_set = set() ans = art_points() if ans: print(*sorted(ans), sep='\n')
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 1 2 3 """ import sys sys.setrecursionlimit(int(1e6)) def generate_adj_table(_v_info): for v_detail in _v_info: source, target = map(int, v_detail) init_adj_table[source].append(target) init_adj_table[target].append(source) return init_adj_table def Tarjan(current, parents, visited, disc, low): global timer current_children_count = 0 visited[current] = True disc[current] = low[current] = timer timer += 1 for adj in adj_table[current]: if not visited[adj]: parents[adj] = current current_children_count += 1 Tarjan(adj, parents, visited, disc, low) low[current] = min(low[current], low[adj]) # current is root of DFS tree if parents[current] == -1 and current_children_count > 1: art_set.add(current) elif parents[current] != -1 and low[adj] >= disc[current]: art_set.add(current) elif adj != parents[current]: low[current] = min(low[current], disc[adj]) # print(timer, parents, visited, disc, low) return None def art_points(): parents = [-1] * vertices visited = [False] * vertices disc = [float('inf')] * vertices low = [float('inf')] * vertices for v in range(vertices): if not visited[v]: Tarjan(v, parents, visited, disc, low) return art_set if __name__ == '__main__': _input = sys.stdin.readlines() vertices, edges = map(int, _input[0].split()) v_info = map(lambda x: x.split(), _input[1:]) init_adj_table = tuple([] for _ in range(vertices)) adj_table = generate_adj_table(v_info) timer = 0 art_set = set() ans = art_points() if ans: print(*sorted(ans), sep='\n')
84
85
1,928
1,960
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 1 2 3 """ import sys sys.setrecursionlimit(int(1e6)) def generate_adj_table(_v_info): for v_detail in _v_info: source, target = map(int, v_detail) init_adj_table[source].append(target) init_adj_table[target].append(source) return init_adj_table def Tarjan(current, parents, visited, disc, low): global timer current_children_count = 0 visited[current] = True disc[current] = low[current] = timer timer += 1 for adj in adj_table[current]: if not visited[adj]: parents[adj] = current current_children_count += 1 Tarjan(adj, parents, visited, disc, low) low[current] = min(low[current], low[adj]) # current is root of DFS tree if parents[current] == -1 and current_children_count > 1: art_set.add(current) elif parents[current] != -1 and low[adj] >= disc[current]: art_set.add(current) elif adj != parents[current]: low[current] = min(low[current], disc[adj]) # print(timer, parents, visited, disc, low) return None def art_points(): parents = [-1] * vertices visited = [False] * vertices disc = [float("inf")] * vertices low = [float("inf")] * vertices for v in range(vertices): Tarjan(v, parents, visited, disc, low) return art_set if __name__ == "__main__": _input = sys.stdin.readlines() vertices, edges = map(int, _input[0].split()) v_info = map(lambda x: x.split(), _input[1:]) init_adj_table = tuple([] for _ in range(vertices)) adj_table = generate_adj_table(v_info) timer = 0 art_set = set() ans = art_points() if ans: print(*sorted(ans), sep="\n")
#!/usr/bin/env python # -*- coding: utf-8 -*- """ input: 5 4 0 1 1 2 2 3 3 4 output: 1 2 3 """ import sys sys.setrecursionlimit(int(1e6)) def generate_adj_table(_v_info): for v_detail in _v_info: source, target = map(int, v_detail) init_adj_table[source].append(target) init_adj_table[target].append(source) return init_adj_table def Tarjan(current, parents, visited, disc, low): global timer current_children_count = 0 visited[current] = True disc[current] = low[current] = timer timer += 1 for adj in adj_table[current]: if not visited[adj]: parents[adj] = current current_children_count += 1 Tarjan(adj, parents, visited, disc, low) low[current] = min(low[current], low[adj]) # current is root of DFS tree if parents[current] == -1 and current_children_count > 1: art_set.add(current) elif parents[current] != -1 and low[adj] >= disc[current]: art_set.add(current) elif adj != parents[current]: low[current] = min(low[current], disc[adj]) # print(timer, parents, visited, disc, low) return None def art_points(): parents = [-1] * vertices visited = [False] * vertices disc = [float("inf")] * vertices low = [float("inf")] * vertices for v in range(vertices): if not visited[v]: Tarjan(v, parents, visited, disc, low) return art_set if __name__ == "__main__": _input = sys.stdin.readlines() vertices, edges = map(int, _input[0].split()) v_info = map(lambda x: x.split(), _input[1:]) init_adj_table = tuple([] for _ in range(vertices)) adj_table = generate_adj_table(v_info) timer = 0 art_set = set() ans = art_points() if ans: print(*sorted(ans), sep="\n")
false
1.176471
[ "- Tarjan(v, parents, visited, disc, low)", "+ if not visited[v]:", "+ Tarjan(v, parents, visited, disc, low)" ]
false
0.088126
0.036987
2.382579
[ "s856196268", "s258108239" ]
u525065967
p02614
python
s709827120
s056343569
69
63
9,184
9,156
Accepted
Accepted
8.7
h, w, k = list(map(int, input().split())) C = [] for _ in range(h): C.append(eval(input())) import itertools ans = 0 for bit in range(1<<(h+w)): c = 0 for i in range(h): for j in range(w): if bit>>(w+i) & 1 and bit>>j & 1: c += C[i][j] == '#' if c == k: ans += 1 print(ans)
h, w, k = list(map(int, input().split())) C = [] for _ in range(h): C.append(eval(input())) import itertools ans = 0 for bit in range(1<<(h+w)): c = 0 for i in range(w, h+w): for j in range(w): if bit>>i & 1 and bit>>j & 1: c += C[i-w][j] == '#' if c == k: ans += 1 print(ans)
12
12
305
308
h, w, k = list(map(int, input().split())) C = [] for _ in range(h): C.append(eval(input())) import itertools ans = 0 for bit in range(1 << (h + w)): c = 0 for i in range(h): for j in range(w): if bit >> (w + i) & 1 and bit >> j & 1: c += C[i][j] == "#" if c == k: ans += 1 print(ans)
h, w, k = list(map(int, input().split())) C = [] for _ in range(h): C.append(eval(input())) import itertools ans = 0 for bit in range(1 << (h + w)): c = 0 for i in range(w, h + w): for j in range(w): if bit >> i & 1 and bit >> j & 1: c += C[i - w][j] == "#" if c == k: ans += 1 print(ans)
false
0
[ "- for i in range(h):", "+ for i in range(w, h + w):", "- if bit >> (w + i) & 1 and bit >> j & 1:", "- c += C[i][j] == \"#\"", "+ if bit >> i & 1 and bit >> j & 1:", "+ c += C[i - w][j] == \"#\"" ]
false
0.12798
0.129496
0.988292
[ "s709827120", "s056343569" ]
u017624958
p03043
python
s932818780
s112841659
119
91
3,444
6,296
Accepted
Accepted
23.53
import math inputted = list(map(int, input().split())) N = inputted[0] K = inputted[1] num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice))) continius_probability = lambda rolls: (1 / 2) ** rolls dice_probablility = lambda N: 1 / N answer = 0 for dice in range(1, N + 1): answer += continius_probability(num_of_rolls(dice, K)) answer *= dice_probablility(N) print(answer)
import math inputted = list(map(int, input().split())) N = inputted[0] K = inputted[1] num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice))) continius_probability = lambda rolls: (1 / 2) ** rolls dice_probablility = lambda N: 1 / N answer = sum([continius_probability(num_of_rolls(dice, K)) for dice in range(1, N + 1)]) answer *= dice_probablility(N) print(answer)
16
14
411
399
import math inputted = list(map(int, input().split())) N = inputted[0] K = inputted[1] num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice))) continius_probability = lambda rolls: (1 / 2) ** rolls dice_probablility = lambda N: 1 / N answer = 0 for dice in range(1, N + 1): answer += continius_probability(num_of_rolls(dice, K)) answer *= dice_probablility(N) print(answer)
import math inputted = list(map(int, input().split())) N = inputted[0] K = inputted[1] num_of_rolls = lambda dice, K: max(0, math.ceil(math.log2(K / dice))) continius_probability = lambda rolls: (1 / 2) ** rolls dice_probablility = lambda N: 1 / N answer = sum([continius_probability(num_of_rolls(dice, K)) for dice in range(1, N + 1)]) answer *= dice_probablility(N) print(answer)
false
12.5
[ "-answer = 0", "-for dice in range(1, N + 1):", "- answer += continius_probability(num_of_rolls(dice, K))", "+answer = sum([continius_probability(num_of_rolls(dice, K)) for dice in range(1, N + 1)])" ]
false
0.074681
0.069476
1.07493
[ "s932818780", "s112841659" ]
u260204064
p02573
python
s400673387
s831712916
653
547
24,560
16,680
Accepted
Accepted
16.23
n, m = list(map(int,input().split())) class unionfind(): def __init__(self,n): self.li = [i for i in range(n+1)] self.group = [1]*(n+1) def find(self, x): while self.li[x]!=x: x = self.li[x] return x def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return; elif x>y: self.li[y] = x self.group[x] += self.group[y] else: self.li[x] = y self.group[y] += self.group[x] x = unionfind(n) ans = 0 for _ in range(m): a,b = list(map(int,input().split())) x.union(a,b) print((max(x.group)))
n, m = list(map(int,input().split())) class unionfind(): def __init__(self,n): self.li = [-1]*(n+1) def find(self, x): if self.li[x]<0: return x else: self.li[x] = self.find(self.li[x]) return self.li[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return; if x>y: x, y = y, x self.li[x]+=self.li[y] self.li[y] = x x = unionfind(n) ans = 0 for _ in range(m): a,b = list(map(int,input().split())) x.union(a,b) print((-min(x.li)))
29
29
680
621
n, m = list(map(int, input().split())) class unionfind: def __init__(self, n): self.li = [i for i in range(n + 1)] self.group = [1] * (n + 1) def find(self, x): while self.li[x] != x: x = self.li[x] return x def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return elif x > y: self.li[y] = x self.group[x] += self.group[y] else: self.li[x] = y self.group[y] += self.group[x] x = unionfind(n) ans = 0 for _ in range(m): a, b = list(map(int, input().split())) x.union(a, b) print((max(x.group)))
n, m = list(map(int, input().split())) class unionfind: def __init__(self, n): self.li = [-1] * (n + 1) def find(self, x): if self.li[x] < 0: return x else: self.li[x] = self.find(self.li[x]) return self.li[x] def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if x > y: x, y = y, x self.li[x] += self.li[y] self.li[y] = x x = unionfind(n) ans = 0 for _ in range(m): a, b = list(map(int, input().split())) x.union(a, b) print((-min(x.li)))
false
0
[ "- self.li = [i for i in range(n + 1)]", "- self.group = [1] * (n + 1)", "+ self.li = [-1] * (n + 1)", "- while self.li[x] != x:", "- x = self.li[x]", "- return x", "+ if self.li[x] < 0:", "+ return x", "+ else:", "+ self.li[x] = self.find(self.li[x])", "+ return self.li[x]", "- elif x > y:", "- self.li[y] = x", "- self.group[x] += self.group[y]", "- else:", "- self.li[x] = y", "- self.group[y] += self.group[x]", "+ if x > y:", "+ x, y = y, x", "+ self.li[x] += self.li[y]", "+ self.li[y] = x", "-print((max(x.group)))", "+print((-min(x.li)))" ]
false
0.042782
0.036666
1.166824
[ "s400673387", "s831712916" ]
u533039576
p02899
python
s792670384
s635702509
188
85
24,192
14,972
Accepted
Accepted
54.79
n = int(eval(input())) a = list(map(int, input().split())) b = [(a[i], i+1) for i in range(n)] b.sort() print((' '.join([str(b[i][1]) for i in range(n)])))
n = int(eval(input())) a = list(map(int, input().split())) b = [0] * n for i in range(n): b[a[i] - 1] = str(i + 1) print((' '.join(b)))
6
8
154
141
n = int(eval(input())) a = list(map(int, input().split())) b = [(a[i], i + 1) for i in range(n)] b.sort() print((" ".join([str(b[i][1]) for i in range(n)])))
n = int(eval(input())) a = list(map(int, input().split())) b = [0] * n for i in range(n): b[a[i] - 1] = str(i + 1) print((" ".join(b)))
false
25
[ "-b = [(a[i], i + 1) for i in range(n)]", "-b.sort()", "-print((\" \".join([str(b[i][1]) for i in range(n)])))", "+b = [0] * n", "+for i in range(n):", "+ b[a[i] - 1] = str(i + 1)", "+print((\" \".join(b)))" ]
false
0.046652
0.039298
1.187129
[ "s792670384", "s635702509" ]
u292810930
p03785
python
s302152677
s341685076
1,750
234
7,384
7,384
Accepted
Accepted
86.63
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for i in range(N)] T.sort() answer = 0 while len(T) > 0: limit = T[0] + K counter = 0 while counter < C: if len(T) == 0: break if T[0] > limit: break del T[0] counter += 1 answer += 1 print(answer)
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for i in range(N)] T.sort() limit = T[0] answer = 1 counter = 1 for i in range(1,N): if T[i] - limit > K or counter == C: limit = T[i] counter = 1 answer += 1 else: counter += 1 print(answer)
16
14
339
298
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for i in range(N)] T.sort() answer = 0 while len(T) > 0: limit = T[0] + K counter = 0 while counter < C: if len(T) == 0: break if T[0] > limit: break del T[0] counter += 1 answer += 1 print(answer)
N, C, K = list(map(int, input().split())) T = [int(eval(input())) for i in range(N)] T.sort() limit = T[0] answer = 1 counter = 1 for i in range(1, N): if T[i] - limit > K or counter == C: limit = T[i] counter = 1 answer += 1 else: counter += 1 print(answer)
false
12.5
[ "-answer = 0", "-while len(T) > 0:", "- limit = T[0] + K", "- counter = 0", "- while counter < C:", "- if len(T) == 0:", "- break", "- if T[0] > limit:", "- break", "- del T[0]", "+limit = T[0]", "+answer = 1", "+counter = 1", "+for i in range(1, N):", "+ if T[i] - limit > K or counter == C:", "+ limit = T[i]", "+ counter = 1", "+ answer += 1", "+ else:", "- answer += 1" ]
false
0.042237
0.037913
1.114033
[ "s302152677", "s341685076" ]
u438662618
p02802
python
s923971486
s297886480
374
339
14,836
13,172
Accepted
Accepted
9.36
n, m = list(map(int, input().split())) resultList = [[0 for i in range(2)] for j in range(n)] #print(resultList) for i in range(m) : result = input().split() prob = int(result[0]) - 1 #print(resultList, result[1]) if result[1] == 'AC' and resultList[prob][0] == 0 : resultList[prob][0] = 1 if result[1] == 'WA' and resultList[prob][0] == 0 : resultList[prob][1] += 1 #print(resultList) ansAC = 0 ansWA = 0 for i in range(n) : ansAC += resultList[i][0] if resultList[i][0] == 1 : ansWA += resultList[i][1] print((ansAC, ansWA))
n, m = list(map(int, input().split())) resultList = [[0] * 2 for i in range(n)] #print(resultList) ansAC = 0 ansWA = 0 for i in range(m) : result = input().split() prob = int(result[0]) - 1 if result[1] == 'AC' and resultList[prob][0] == 0 : resultList[prob][0]= 1 ansAC += 1 ansWA += resultList[prob][1] if result[1] == 'WA' and resultList[prob][0] == 0 : resultList[prob][1] += 1 print((ansAC, ansWA))
22
16
595
460
n, m = list(map(int, input().split())) resultList = [[0 for i in range(2)] for j in range(n)] # print(resultList) for i in range(m): result = input().split() prob = int(result[0]) - 1 # print(resultList, result[1]) if result[1] == "AC" and resultList[prob][0] == 0: resultList[prob][0] = 1 if result[1] == "WA" and resultList[prob][0] == 0: resultList[prob][1] += 1 # print(resultList) ansAC = 0 ansWA = 0 for i in range(n): ansAC += resultList[i][0] if resultList[i][0] == 1: ansWA += resultList[i][1] print((ansAC, ansWA))
n, m = list(map(int, input().split())) resultList = [[0] * 2 for i in range(n)] # print(resultList) ansAC = 0 ansWA = 0 for i in range(m): result = input().split() prob = int(result[0]) - 1 if result[1] == "AC" and resultList[prob][0] == 0: resultList[prob][0] = 1 ansAC += 1 ansWA += resultList[prob][1] if result[1] == "WA" and resultList[prob][0] == 0: resultList[prob][1] += 1 print((ansAC, ansWA))
false
27.272727
[ "-resultList = [[0 for i in range(2)] for j in range(n)]", "+resultList = [[0] * 2 for i in range(n)]", "+ansAC = 0", "+ansWA = 0", "- # print(resultList, result[1])", "+ ansAC += 1", "+ ansWA += resultList[prob][1]", "-# print(resultList)", "-ansAC = 0", "-ansWA = 0", "-for i in range(n):", "- ansAC += resultList[i][0]", "- if resultList[i][0] == 1:", "- ansWA += resultList[i][1]" ]
false
0.050503
0.041564
1.215062
[ "s923971486", "s297886480" ]
u680851063
p02780
python
s154033746
s985487232
178
137
31,968
32,432
Accepted
Accepted
23.03
#サイコロの目からk個ずつ順にループで切り出して和をリストするとTLE #累積和のリストから、k個の和のリスト → 期待値のリストでTLE解消 from itertools import accumulate n, k = list(map(int,input().split())) l = list(map(int,input().split())) p = [0] + list(accumulate(l)) q = [] #累積和'p'からから求めたk個ずつの和 r = [] #出目の期待値 for i in range(n-k+1): q.append(p[i+k] - p[i]) r.append((q[i] + k) / 2) print((max(r)))
n,k = list(map(int, input().split())) l = list(map(int, input().split())) # 期待値:マス目の総和/マス目の数, マス目の最大値+最小値[1]/2 l = [(i+1)/2 for i in l] # 期待値に変換 # 累積和を取得 from itertools import accumulate cum = [0] + list(accumulate(l)) # 差分を考慮しつつ k個の和をリストする → 最大値が ans sum_k = [] for j in range(n-k+1): sum_k.append(cum[k+j] - cum[j]) print((max(sum_k)))
17
16
360
353
# サイコロの目からk個ずつ順にループで切り出して和をリストするとTLE # 累積和のリストから、k個の和のリスト → 期待値のリストでTLE解消 from itertools import accumulate n, k = list(map(int, input().split())) l = list(map(int, input().split())) p = [0] + list(accumulate(l)) q = [] # 累積和'p'からから求めたk個ずつの和 r = [] # 出目の期待値 for i in range(n - k + 1): q.append(p[i + k] - p[i]) r.append((q[i] + k) / 2) print((max(r)))
n, k = list(map(int, input().split())) l = list(map(int, input().split())) # 期待値:マス目の総和/マス目の数, マス目の最大値+最小値[1]/2 l = [(i + 1) / 2 for i in l] # 期待値に変換 # 累積和を取得 from itertools import accumulate cum = [0] + list(accumulate(l)) # 差分を考慮しつつ k個の和をリストする → 最大値が ans sum_k = [] for j in range(n - k + 1): sum_k.append(cum[k + j] - cum[j]) print((max(sum_k)))
false
5.882353
[ "-# サイコロの目からk個ずつ順にループで切り出して和をリストするとTLE", "-# 累積和のリストから、k個の和のリスト → 期待値のリストでTLE解消", "+n, k = list(map(int, input().split()))", "+l = list(map(int, input().split()))", "+# 期待値:マス目の総和/マス目の数, マス目の最大値+最小値[1]/2", "+l = [(i + 1) / 2 for i in l] # 期待値に変換", "+# 累積和を取得", "-n, k = list(map(int, input().split()))", "-l = list(map(int, input().split()))", "-p = [0] + list(accumulate(l))", "-q = [] # 累積和'p'からから求めたk個ずつの和", "-r = [] # 出目の期待値", "-for i in range(n - k + 1):", "- q.append(p[i + k] - p[i])", "- r.append((q[i] + k) / 2)", "-print((max(r)))", "+cum = [0] + list(accumulate(l))", "+# 差分を考慮しつつ k個の和をリストする → 最大値が ans", "+sum_k = []", "+for j in range(n - k + 1):", "+ sum_k.append(cum[k + j] - cum[j])", "+print((max(sum_k)))" ]
false
0.046509
0.110502
0.420889
[ "s154033746", "s985487232" ]
u072053884
p02368
python
s013080647
s027762443
380
340
11,152
11,228
Accepted
Accepted
10.53
# Acceptance of input import sys file_input = sys.stdin V, E = list(map(int, file_input.readline().split())) adj = [[] for i in range(V)] for i in range(E): s, t = list(map(int, file_input.readline().split())) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import collections S = collections.deque() path = collections.deque() index = 0 indices = [None] * V lowlink = [None] * V onStack = [False] * V scc_id = [None] * V parent = [0] * V for v in range(V): if not indices[v]: index += 1 indices[v] = index lowlink[v] = index S.append(v) path.append(v) onStack[v] = True while path: s = path[-1] adj_v = adj[s] for t in adj_v: if not indices[t]: parent[t] = s path.append(t) S.append(t) index += 1 indices[t] = index lowlink[t] = index onStack[t] = True break if s == path[-1]: for t in adj_v: if onStack[t]: lowlink[s] = min(lowlink[s], lowlink[t]) p = parent[s] lowlink[p] = min(lowlink[p], lowlink[s]) if indices[s] == lowlink[s]: while S: w = S.pop() onStack[w] =False scc_id[w] = s if w == s: break path.pop() # Output Q = file_input.readline() for line in file_input: u, v = list(map(int, line.split())) if scc_id[u] == scc_id[v]: print((1)) else: print((0))
# Acceptance of input import sys file_input = sys.stdin V, E = list(map(int, file_input.readline().split())) adj = [[] for i in range(V)] for i in range(E): s, t = list(map(int, file_input.readline().split())) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import collections S = collections.deque() path = collections.deque() index = 0 indices = [None] * V lowlink = [None] * V onStack = [False] * V scc_id = [None] * V parent = [0] * V for v in range(V): if not indices[v]: index += 1 indices[v] = index lowlink[v] = index S.append(v) path.append(v) onStack[v] = True while path: s = path[-1] adj_v = adj[s] for t in adj_v: if not indices[t]: parent[t] = s path.append(t) S.append(t) index += 1 indices[t] = index lowlink[t] = index onStack[t] = True adj_v.remove(t) break if s == path[-1]: for t in adj_v: if onStack[t]: lowlink[s] = min(lowlink[s], lowlink[t]) p = parent[s] lowlink[p] = min(lowlink[p], lowlink[s]) if indices[s] == lowlink[s]: while S: w = S.pop() onStack[w] =False scc_id[w] = s if w == s: break path.pop() # Output Q = file_input.readline() for line in file_input: u, v = list(map(int, line.split())) if scc_id[u] == scc_id[v]: print((1)) else: print((0))
72
73
1,844
1,881
# Acceptance of input import sys file_input = sys.stdin V, E = list(map(int, file_input.readline().split())) adj = [[] for i in range(V)] for i in range(E): s, t = list(map(int, file_input.readline().split())) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import collections S = collections.deque() path = collections.deque() index = 0 indices = [None] * V lowlink = [None] * V onStack = [False] * V scc_id = [None] * V parent = [0] * V for v in range(V): if not indices[v]: index += 1 indices[v] = index lowlink[v] = index S.append(v) path.append(v) onStack[v] = True while path: s = path[-1] adj_v = adj[s] for t in adj_v: if not indices[t]: parent[t] = s path.append(t) S.append(t) index += 1 indices[t] = index lowlink[t] = index onStack[t] = True break if s == path[-1]: for t in adj_v: if onStack[t]: lowlink[s] = min(lowlink[s], lowlink[t]) p = parent[s] lowlink[p] = min(lowlink[p], lowlink[s]) if indices[s] == lowlink[s]: while S: w = S.pop() onStack[w] = False scc_id[w] = s if w == s: break path.pop() # Output Q = file_input.readline() for line in file_input: u, v = list(map(int, line.split())) if scc_id[u] == scc_id[v]: print((1)) else: print((0))
# Acceptance of input import sys file_input = sys.stdin V, E = list(map(int, file_input.readline().split())) adj = [[] for i in range(V)] for i in range(E): s, t = list(map(int, file_input.readline().split())) adj[s].append(t) # Tarjan's strongly connected components algorithm(repetition) import collections S = collections.deque() path = collections.deque() index = 0 indices = [None] * V lowlink = [None] * V onStack = [False] * V scc_id = [None] * V parent = [0] * V for v in range(V): if not indices[v]: index += 1 indices[v] = index lowlink[v] = index S.append(v) path.append(v) onStack[v] = True while path: s = path[-1] adj_v = adj[s] for t in adj_v: if not indices[t]: parent[t] = s path.append(t) S.append(t) index += 1 indices[t] = index lowlink[t] = index onStack[t] = True adj_v.remove(t) break if s == path[-1]: for t in adj_v: if onStack[t]: lowlink[s] = min(lowlink[s], lowlink[t]) p = parent[s] lowlink[p] = min(lowlink[p], lowlink[s]) if indices[s] == lowlink[s]: while S: w = S.pop() onStack[w] = False scc_id[w] = s if w == s: break path.pop() # Output Q = file_input.readline() for line in file_input: u, v = list(map(int, line.split())) if scc_id[u] == scc_id[v]: print((1)) else: print((0))
false
1.369863
[ "+ adj_v.remove(t)" ]
false
0.043891
0.045123
0.972697
[ "s013080647", "s027762443" ]
u798818115
p03994
python
s470466640
s541899923
124
53
4,152
4,216
Accepted
Accepted
57.26
s=list(eval(input())) N=int(eval(input())) apple=lambda c:ord(c)-ord("a")+1 l=[] for i in range(len(s)): s[i]=apple(s[i]) dif=27-s[i] if s[i]==1: pass elif dif<=N: N-=dif s[i]=1 s[-1]-=1 s[-1]=(s[-1]+N)%26 s[-1]+=1 kiss = lambda c: chr(c+96) for i in range(len(s)): s[i]=kiss(s[i]) print(("".join(s)))
# coding: utf-8 # Your code here! s=eval(input()) K=int(eval(input())) ans=[] #122 for item in s[:len(s)-1]: cost=(123-ord(item)) if item=="a": ans.append(item) continue if K>=cost: K-=cost ans.append("a") else: ans.append(item) K%=26 last=ord(s[-1]) if last+K>122: ans.append(chr(last+K-26)) else: ans.append(chr(last+K)) print(("".join(ans)))
24
27
359
428
s = list(eval(input())) N = int(eval(input())) apple = lambda c: ord(c) - ord("a") + 1 l = [] for i in range(len(s)): s[i] = apple(s[i]) dif = 27 - s[i] if s[i] == 1: pass elif dif <= N: N -= dif s[i] = 1 s[-1] -= 1 s[-1] = (s[-1] + N) % 26 s[-1] += 1 kiss = lambda c: chr(c + 96) for i in range(len(s)): s[i] = kiss(s[i]) print(("".join(s)))
# coding: utf-8 # Your code here! s = eval(input()) K = int(eval(input())) ans = [] # 122 for item in s[: len(s) - 1]: cost = 123 - ord(item) if item == "a": ans.append(item) continue if K >= cost: K -= cost ans.append("a") else: ans.append(item) K %= 26 last = ord(s[-1]) if last + K > 122: ans.append(chr(last + K - 26)) else: ans.append(chr(last + K)) print(("".join(ans)))
false
11.111111
[ "-s = list(eval(input()))", "-N = int(eval(input()))", "-apple = lambda c: ord(c) - ord(\"a\") + 1", "-l = []", "-for i in range(len(s)):", "- s[i] = apple(s[i])", "- dif = 27 - s[i]", "- if s[i] == 1:", "- pass", "- elif dif <= N:", "- N -= dif", "- s[i] = 1", "-s[-1] -= 1", "-s[-1] = (s[-1] + N) % 26", "-s[-1] += 1", "-kiss = lambda c: chr(c + 96)", "-for i in range(len(s)):", "- s[i] = kiss(s[i])", "-print((\"\".join(s)))", "+# coding: utf-8", "+# Your code here!", "+s = eval(input())", "+K = int(eval(input()))", "+ans = []", "+# 122", "+for item in s[: len(s) - 1]:", "+ cost = 123 - ord(item)", "+ if item == \"a\":", "+ ans.append(item)", "+ continue", "+ if K >= cost:", "+ K -= cost", "+ ans.append(\"a\")", "+ else:", "+ ans.append(item)", "+K %= 26", "+last = ord(s[-1])", "+if last + K > 122:", "+ ans.append(chr(last + K - 26))", "+else:", "+ ans.append(chr(last + K))", "+print((\"\".join(ans)))" ]
false
0.045868
0.039025
1.17535
[ "s470466640", "s541899923" ]
u391819434
p03109
python
s538649530
s212674885
19
17
3,060
2,940
Accepted
Accepted
10.53
Y,M,D=list(map(int,input().split('/'))) if Y < 2019: print('Heisei') elif Y == 2019 and M <= 4: print('Heisei') else: print('TBD')
S=eval(input()) if S[5:7]>'04': print('TBD') else: print('Heisei')
8
6
144
74
Y, M, D = list(map(int, input().split("/"))) if Y < 2019: print("Heisei") elif Y == 2019 and M <= 4: print("Heisei") else: print("TBD")
S = eval(input()) if S[5:7] > "04": print("TBD") else: print("Heisei")
false
25
[ "-Y, M, D = list(map(int, input().split(\"/\")))", "-if Y < 2019:", "+S = eval(input())", "+if S[5:7] > \"04\":", "+ print(\"TBD\")", "+else:", "-elif Y == 2019 and M <= 4:", "- print(\"Heisei\")", "-else:", "- print(\"TBD\")" ]
false
0.066948
0.069885
0.957969
[ "s538649530", "s212674885" ]
u614314290
p03078
python
s065367139
s402850552
1,054
777
149,648
4,468
Accepted
Accepted
26.28
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) ab = [] for a in A: for b in B: ab += [a + b] ab3000 = sorted(ab)[::-1][:3000] abc = [] for ab in ab3000: for c in C: abc += [ab + c] abc.sort(reverse=True) for k in range(K): print((abc[k]))
import heapq X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) a = sorted(A, reverse=True) b = sorted(B, reverse=True) c = sorted(C, reverse=True) added = [(0, 0, 0)] cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)] for k in range(K): v = heapq.heappop(cakes) print((-v[0])) va, vb, vc = v[1:] if va < X - 1 and (va + 1, vb, vc) not in added: heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc)) added += [(va + 1, vb, vc)] if vb < Y - 1 and (va, vb + 1, vc) not in added: heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc)) added += [(va, vb + 1, vc)] if vc < Z - 1 and (va, vb, vc + 1) not in added: heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1)) added += [(va, vb, vc + 1)]
21
26
369
870
X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) ab = [] for a in A: for b in B: ab += [a + b] ab3000 = sorted(ab)[::-1][:3000] abc = [] for ab in ab3000: for c in C: abc += [ab + c] abc.sort(reverse=True) for k in range(K): print((abc[k]))
import heapq X, Y, Z, K = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) a = sorted(A, reverse=True) b = sorted(B, reverse=True) c = sorted(C, reverse=True) added = [(0, 0, 0)] cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)] for k in range(K): v = heapq.heappop(cakes) print((-v[0])) va, vb, vc = v[1:] if va < X - 1 and (va + 1, vb, vc) not in added: heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc)) added += [(va + 1, vb, vc)] if vb < Y - 1 and (va, vb + 1, vc) not in added: heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc)) added += [(va, vb + 1, vc)] if vc < Z - 1 and (va, vb, vc + 1) not in added: heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1)) added += [(va, vb, vc + 1)]
false
19.230769
[ "+import heapq", "+", "-ab = []", "-for a in A:", "- for b in B:", "- ab += [a + b]", "-ab3000 = sorted(ab)[::-1][:3000]", "-abc = []", "-for ab in ab3000:", "- for c in C:", "- abc += [ab + c]", "-abc.sort(reverse=True)", "+a = sorted(A, reverse=True)", "+b = sorted(B, reverse=True)", "+c = sorted(C, reverse=True)", "+added = [(0, 0, 0)]", "+cakes = [(-(a[0] + b[0] + c[0]), 0, 0, 0)]", "- print((abc[k]))", "+ v = heapq.heappop(cakes)", "+ print((-v[0]))", "+ va, vb, vc = v[1:]", "+ if va < X - 1 and (va + 1, vb, vc) not in added:", "+ heapq.heappush(cakes, (-(a[va + 1] + b[vb] + c[vc]), va + 1, vb, vc))", "+ added += [(va + 1, vb, vc)]", "+ if vb < Y - 1 and (va, vb + 1, vc) not in added:", "+ heapq.heappush(cakes, (-(a[va] + b[vb + 1] + c[vc]), va, vb + 1, vc))", "+ added += [(va, vb + 1, vc)]", "+ if vc < Z - 1 and (va, vb, vc + 1) not in added:", "+ heapq.heappush(cakes, (-(a[va] + b[vb] + c[vc + 1]), va, vb, vc + 1))", "+ added += [(va, vb, vc + 1)]" ]
false
0.104081
0.078888
1.319349
[ "s065367139", "s402850552" ]
u074220993
p04045
python
s400881817
s604196490
38
32
9,116
9,100
Accepted
Accepted
15.79
N, L = list(map(int, input().split())) S = {int(x) for x in input().split()} flag = False while flag == False: if N%10 in S: N += 1 continue if int((N%100-N%10)/10) in S and N >= 10: N += 1 continue if int((N%1000-N%100)/100) in S and N >= 100: N += 1 continue if int((N%10000-N%1000)/1000) in S and N >= 1000: N += 1 continue if int((N%100000-N%10000)/10000) in S and N >= 10000: N += 1 continue flag = True print(N)
N, L = list(map(int, input().split())) S = {int(x) for x in input().split()} flag = False while 1: if N%10 in S: N += 1 continue if int((N%100-N%10)/10) in S and N >= 10: N += 1 continue if int((N%1000-N%100)/100) in S and N >= 100: N += 1 continue if int((N%10000-N%1000)/1000) in S and N >= 1000: N += 1 continue if int((N%100000-N%10000)/10000) in S and N >= 10000: N += 1 continue break print(N)
21
21
536
518
N, L = list(map(int, input().split())) S = {int(x) for x in input().split()} flag = False while flag == False: if N % 10 in S: N += 1 continue if int((N % 100 - N % 10) / 10) in S and N >= 10: N += 1 continue if int((N % 1000 - N % 100) / 100) in S and N >= 100: N += 1 continue if int((N % 10000 - N % 1000) / 1000) in S and N >= 1000: N += 1 continue if int((N % 100000 - N % 10000) / 10000) in S and N >= 10000: N += 1 continue flag = True print(N)
N, L = list(map(int, input().split())) S = {int(x) for x in input().split()} flag = False while 1: if N % 10 in S: N += 1 continue if int((N % 100 - N % 10) / 10) in S and N >= 10: N += 1 continue if int((N % 1000 - N % 100) / 100) in S and N >= 100: N += 1 continue if int((N % 10000 - N % 1000) / 1000) in S and N >= 1000: N += 1 continue if int((N % 100000 - N % 10000) / 10000) in S and N >= 10000: N += 1 continue break print(N)
false
0
[ "-while flag == False:", "+while 1:", "- flag = True", "+ break" ]
false
0.040808
0.046924
0.869677
[ "s400881817", "s604196490" ]
u353919145
p03331
python
s330262070
s975782054
259
171
4,740
3,060
Accepted
Accepted
33.98
n=int(input()) ret=[] for y in range(n/2): a=y+1 b=n-a r1 = 0 r2 = 0 for i in str(a): r1 += int(i) for x in str(b): r2 += int(x) r=r1+r2 ret.append(r) print(min(ret))
a = int(eval(input())) lim = a // 2 soma_lista = [] menor = 100000 for i in range(a - 1, lim, -1): b = str(a - abs(i)) + str(abs(i)) soma = 0 for digit in b: soma += int(digit) if soma < menor: menor = soma if a == 2: print(a) else: print(menor)
14
15
194
294
n = int(input()) ret = [] for y in range(n / 2): a = y + 1 b = n - a r1 = 0 r2 = 0 for i in str(a): r1 += int(i) for x in str(b): r2 += int(x) r = r1 + r2 ret.append(r) print(min(ret))
a = int(eval(input())) lim = a // 2 soma_lista = [] menor = 100000 for i in range(a - 1, lim, -1): b = str(a - abs(i)) + str(abs(i)) soma = 0 for digit in b: soma += int(digit) if soma < menor: menor = soma if a == 2: print(a) else: print(menor)
false
6.666667
[ "-n = int(input())", "-ret = []", "-for y in range(n / 2):", "- a = y + 1", "- b = n - a", "- r1 = 0", "- r2 = 0", "- for i in str(a):", "- r1 += int(i)", "- for x in str(b):", "- r2 += int(x)", "- r = r1 + r2", "- ret.append(r)", "-print(min(ret))", "+a = int(eval(input()))", "+lim = a // 2", "+soma_lista = []", "+menor = 100000", "+for i in range(a - 1, lim, -1):", "+ b = str(a - abs(i)) + str(abs(i))", "+ soma = 0", "+ for digit in b:", "+ soma += int(digit)", "+ if soma < menor:", "+ menor = soma", "+if a == 2:", "+ print(a)", "+else:", "+ print(menor)" ]
false
0.042992
0.089628
0.479672
[ "s330262070", "s975782054" ]
u546285759
p00056
python
s064501833
s393463978
2,440
1,850
8,264
8,276
Accepted
Accepted
24.18
import bisect primes = [0, 0] + [1] * 49999 for i in range(2, 225): if primes[i]: for j in range(i*i, 50001, i): primes[j] = 0 values = [i for i, k in enumerate(primes) if k] while True: n = int(eval(input())) if n == 0: break I = bisect.bisect(values, n//2) print((sum(primes[n-v] for v in values[:I])))
import bisect primes = [0, 0] + [1] * 49999 for i in range(2, 225): if primes[i]: for j in range(i*i, 50001, i): primes[j] = 0 values = [i for i, k in enumerate(primes) if k] while True: n = int(eval(input())) if n == 0: break I = bisect.bisect(values, n//2) print((sum(1 for v in values[:I] if primes[n-v])))
13
13
356
361
import bisect primes = [0, 0] + [1] * 49999 for i in range(2, 225): if primes[i]: for j in range(i * i, 50001, i): primes[j] = 0 values = [i for i, k in enumerate(primes) if k] while True: n = int(eval(input())) if n == 0: break I = bisect.bisect(values, n // 2) print((sum(primes[n - v] for v in values[:I])))
import bisect primes = [0, 0] + [1] * 49999 for i in range(2, 225): if primes[i]: for j in range(i * i, 50001, i): primes[j] = 0 values = [i for i, k in enumerate(primes) if k] while True: n = int(eval(input())) if n == 0: break I = bisect.bisect(values, n // 2) print((sum(1 for v in values[:I] if primes[n - v])))
false
0
[ "- print((sum(primes[n - v] for v in values[:I])))", "+ print((sum(1 for v in values[:I] if primes[n - v])))" ]
false
0.069308
0.06908
1.003301
[ "s064501833", "s393463978" ]
u968166680
p02882
python
s454602553
s599558277
168
27
38,256
9,256
Accepted
Accepted
83.93
import sys from math import atan, degrees read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 def main(): a, b, x = list(map(int, readline().split())) if x > a * a * b / 2: ans = atan((2 * a * a * b - 2 * x) / (a ** 3)) else: ans = atan(a * b * b / (2 * x)) print((degrees(ans))) return if __name__ == '__main__': main()
import sys from math import atan, degrees read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10 ** 9) INF = 1 << 60 MOD = 1000000007 def main(): a, b, x = list(map(int, readline().split())) if x > a * a * b / 2: ans = atan(2 * (a * a * b - x) / (a ** 3)) else: ans = atan(a * b * b / (2 * x)) print((degrees(ans))) return if __name__ == '__main__': main()
23
25
458
474
import sys from math import atan, degrees read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 def main(): a, b, x = list(map(int, readline().split())) if x > a * a * b / 2: ans = atan((2 * a * a * b - 2 * x) / (a**3)) else: ans = atan(a * b * b / (2 * x)) print((degrees(ans))) return if __name__ == "__main__": main()
import sys from math import atan, degrees read = sys.stdin.read readline = sys.stdin.readline readlines = sys.stdin.readlines sys.setrecursionlimit(10**9) INF = 1 << 60 MOD = 1000000007 def main(): a, b, x = list(map(int, readline().split())) if x > a * a * b / 2: ans = atan(2 * (a * a * b - x) / (a**3)) else: ans = atan(a * b * b / (2 * x)) print((degrees(ans))) return if __name__ == "__main__": main()
false
8
[ "+MOD = 1000000007", "- ans = atan((2 * a * a * b - 2 * x) / (a**3))", "+ ans = atan(2 * (a * a * b - x) / (a**3))" ]
false
0.078311
0.043122
1.816038
[ "s454602553", "s599558277" ]
u595289165
p03315
python
s796869445
s501636614
20
17
2,940
2,940
Accepted
Accepted
15
s = list(eval(input())) ans = 0 for i in s: if i == "+": ans += 1 else: ans -= 1 print(ans)
s = list(eval(input())) print((s.count("+") - s.count("-")))
8
2
116
53
s = list(eval(input())) ans = 0 for i in s: if i == "+": ans += 1 else: ans -= 1 print(ans)
s = list(eval(input())) print((s.count("+") - s.count("-")))
false
75
[ "-ans = 0", "-for i in s:", "- if i == \"+\":", "- ans += 1", "- else:", "- ans -= 1", "-print(ans)", "+print((s.count(\"+\") - s.count(\"-\")))" ]
false
0.050906
0.047677
1.067723
[ "s796869445", "s501636614" ]
u875291233
p02998
python
s092745558
s336424654
1,230
817
144,260
91,224
Accepted
Accepted
33.58
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n,xy): self.parent = list(range(n))#親ノード self.size = [1]*n #グループの要素数 self.xval = [{x} for x,y in xy] self.yval = [{y} for x,y in xy] def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: x, self.parent[x] = self.parent[x], self.parent[self.parent[x]] return x def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる x, y = self.root(x), self.root(y) if x == y: return False if self.size[x] < self.size[y]: self.size[y] += self.size[x] #yの要素数を更新 self.parent[x] = y #xをyにつなぐ self.xval[y].update(self.xval[x]) self.yval[y].update(self.yval[x]) else: self.size[x] += self.size[y] #xの要素数を更新 self.parent[y] = x #yをxにつなぐ self.xval[x].update(self.xval[y]) self.yval[x].update(self.yval[y]) return True def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue return self.root(x) == self.root(y) def size(self,x): #size(x): xのいるグループの要素数を返す return self.size[self.root(x)] n = int(eval(input())) xy = [[int(i) for i in input().split()] for j in range(n)] UF = UnionFind(n,xy) xval = dict() yval = dict() for i,(x,y) in enumerate(xy): if y in yval: UF.merge(i,yval[y]) else: yval[y] = i if x in xval: UF.merge(i,xval[x]) else: xval[x] = i ans = -n for i,pi in enumerate(UF.parent): if i==pi: ans += len(UF.xval[pi]) * len(UF.yval[pi]) #print(xval,yval) print(ans)
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n))#親ノード self.size = [1]*n #グループの要素数 def root(self, x): #root(x): xの根ノードを返す. while self.parent[x] != x: x, self.parent[x] = self.parent[x], self.parent[self.parent[x]] return x def merge(self, x, y): #merge(x,y): xのいるグループと$y$のいるグループをまとめる x, y = self.root(x), self.root(y) if x == y: return False if self.size[x] < self.size[y]: self.size[y] += self.size[x] #yの要素数を更新 self.parent[x] = y #xをyにつなぐ else: self.size[x] += self.size[y] #xの要素数を更新 self.parent[y] = x #yをxにつなぐ return True def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue return self.root(x) == self.root(y) def size(self,x): #size(x): xのいるグループの要素数を返す return self.size[self.root(x)] n = int(eval(input())) xy = [[int(i) for i in input().split()] for j in range(n)] UF = UnionFind(n) xval = dict() yval = dict() for i,(x,y) in enumerate(xy): if y in yval: UF.merge(i,yval[y]) else: yval[y] = i if x in xval: UF.merge(i,xval[x]) else: xval[x] = i xcon = dict() ycon = dict() for i in range(n): pi = UF.root(i) x,y = xy[i] if pi in xcon: xcon[pi].add(x) else: xcon[pi] = {x} if pi in ycon: ycon[pi].add(y) else: ycon[pi] = {y} ans = -n #print(xcon,ycon) for key, val in list(xcon.items()): ans += len(val) * len(ycon[key]) #print(UF.parent) #print(xval,yval) print(ans)
67
80
1,732
1,727
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n, xy): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 self.xval = [{x} for x, y in xy] self.yval = [{y} for x, y in xy] def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: x, self.parent[x] = self.parent[x], self.parent[self.parent[x]] return x def merge(self, x, y): # merge(x,y): xのいるグループと$y$のいるグループをまとめる x, y = self.root(x), self.root(y) if x == y: return False if self.size[x] < self.size[y]: self.size[y] += self.size[x] # yの要素数を更新 self.parent[x] = y # xをyにつなぐ self.xval[y].update(self.xval[x]) self.yval[y].update(self.yval[x]) else: self.size[x] += self.size[y] # xの要素数を更新 self.parent[y] = x # yをxにつなぐ self.xval[x].update(self.xval[y]) self.yval[x].update(self.yval[y]) return True def issame(self, x, y): # same(x,y): xとyが同じグループにあるならTrue return self.root(x) == self.root(y) def size(self, x): # size(x): xのいるグループの要素数を返す return self.size[self.root(x)] n = int(eval(input())) xy = [[int(i) for i in input().split()] for j in range(n)] UF = UnionFind(n, xy) xval = dict() yval = dict() for i, (x, y) in enumerate(xy): if y in yval: UF.merge(i, yval[y]) else: yval[y] = i if x in xval: UF.merge(i, xval[x]) else: xval[x] = i ans = -n for i, pi in enumerate(UF.parent): if i == pi: ans += len(UF.xval[pi]) * len(UF.yval[pi]) # print(xval,yval) print(ans)
# coding: utf-8 # Your code here! class UnionFind: def __init__(self, n): self.parent = list(range(n)) # 親ノード self.size = [1] * n # グループの要素数 def root(self, x): # root(x): xの根ノードを返す. while self.parent[x] != x: x, self.parent[x] = self.parent[x], self.parent[self.parent[x]] return x def merge(self, x, y): # merge(x,y): xのいるグループと$y$のいるグループをまとめる x, y = self.root(x), self.root(y) if x == y: return False if self.size[x] < self.size[y]: self.size[y] += self.size[x] # yの要素数を更新 self.parent[x] = y # xをyにつなぐ else: self.size[x] += self.size[y] # xの要素数を更新 self.parent[y] = x # yをxにつなぐ return True def issame(self, x, y): # same(x,y): xとyが同じグループにあるならTrue return self.root(x) == self.root(y) def size(self, x): # size(x): xのいるグループの要素数を返す return self.size[self.root(x)] n = int(eval(input())) xy = [[int(i) for i in input().split()] for j in range(n)] UF = UnionFind(n) xval = dict() yval = dict() for i, (x, y) in enumerate(xy): if y in yval: UF.merge(i, yval[y]) else: yval[y] = i if x in xval: UF.merge(i, xval[x]) else: xval[x] = i xcon = dict() ycon = dict() for i in range(n): pi = UF.root(i) x, y = xy[i] if pi in xcon: xcon[pi].add(x) else: xcon[pi] = {x} if pi in ycon: ycon[pi].add(y) else: ycon[pi] = {y} ans = -n # print(xcon,ycon) for key, val in list(xcon.items()): ans += len(val) * len(ycon[key]) # print(UF.parent) # print(xval,yval) print(ans)
false
16.25
[ "- def __init__(self, n, xy):", "+ def __init__(self, n):", "- self.xval = [{x} for x, y in xy]", "- self.yval = [{y} for x, y in xy]", "- self.xval[y].update(self.xval[x])", "- self.yval[y].update(self.yval[x])", "- self.xval[x].update(self.xval[y])", "- self.yval[x].update(self.yval[y])", "-UF = UnionFind(n, xy)", "+UF = UnionFind(n)", "+xcon = dict()", "+ycon = dict()", "+for i in range(n):", "+ pi = UF.root(i)", "+ x, y = xy[i]", "+ if pi in xcon:", "+ xcon[pi].add(x)", "+ else:", "+ xcon[pi] = {x}", "+ if pi in ycon:", "+ ycon[pi].add(y)", "+ else:", "+ ycon[pi] = {y}", "-for i, pi in enumerate(UF.parent):", "- if i == pi:", "- ans += len(UF.xval[pi]) * len(UF.yval[pi])", "+# print(xcon,ycon)", "+for key, val in list(xcon.items()):", "+ ans += len(val) * len(ycon[key])", "+# print(UF.parent)" ]
false
0.03601
0.033282
1.08197
[ "s092745558", "s336424654" ]
u044964932
p02572
python
s251499320
s099561894
367
201
49,972
49,968
Accepted
Accepted
45.23
import numpy as np def main(): n = int(eval(input())) As = list(map(int, input().split())) mod = 10**9 + 7 As_sum = np.sum(As) % mod ans = 0 for i in range(n): As_sum -= As[i] As_sum %= mod ans += As_sum * As[i] ans %= mod ans %= mod print(ans) if __name__ == "__main__": main()
import numpy as np def main(): n = int(eval(input())) As = list(map(int, input().split())) mod = 10 ** 9 + 7 As_sum = sum(As) ans = 0 for i in range(n): As_sum -= As[i] ans += As_sum * As[i] ans %= mod ans %= mod print(ans) if __name__ == "__main__": main()
21
22
366
340
import numpy as np def main(): n = int(eval(input())) As = list(map(int, input().split())) mod = 10**9 + 7 As_sum = np.sum(As) % mod ans = 0 for i in range(n): As_sum -= As[i] As_sum %= mod ans += As_sum * As[i] ans %= mod ans %= mod print(ans) if __name__ == "__main__": main()
import numpy as np def main(): n = int(eval(input())) As = list(map(int, input().split())) mod = 10**9 + 7 As_sum = sum(As) ans = 0 for i in range(n): As_sum -= As[i] ans += As_sum * As[i] ans %= mod ans %= mod print(ans) if __name__ == "__main__": main()
false
4.545455
[ "- As_sum = np.sum(As) % mod", "+ As_sum = sum(As)", "- As_sum %= mod" ]
false
0.166478
0.041159
4.044709
[ "s251499320", "s099561894" ]
u761320129
p03733
python
s140448154
s973229379
156
143
25,200
25,196
Accepted
Accepted
8.33
N,T = list(map(int,input().split())) ts = list(map(int,input().split())) ans = 0 until = 0 for t in ts: ans += min(T, t+T-until) until = t+T print(ans)
N,T = list(map(int,input().split())) ts = list(map(int,input().split())) ans = 0 prev = ts[0] for t in ts[1:]: ans += min(T, t-prev) prev = t ans += T print(ans)
9
10
162
173
N, T = list(map(int, input().split())) ts = list(map(int, input().split())) ans = 0 until = 0 for t in ts: ans += min(T, t + T - until) until = t + T print(ans)
N, T = list(map(int, input().split())) ts = list(map(int, input().split())) ans = 0 prev = ts[0] for t in ts[1:]: ans += min(T, t - prev) prev = t ans += T print(ans)
false
10
[ "-until = 0", "-for t in ts:", "- ans += min(T, t + T - until)", "- until = t + T", "+prev = ts[0]", "+for t in ts[1:]:", "+ ans += min(T, t - prev)", "+ prev = t", "+ans += T" ]
false
0.134348
0.044339
3.030051
[ "s140448154", "s973229379" ]
u031157253
p02693
python
s162785949
s363362861
22
20
9,176
9,164
Accepted
Accepted
9.09
K = int(eval(input())) A, B = list(map(int, input().split())) while True: if A % K == 0: print('OK') break A += 1 if A == B + 1: print('NG') break
K = int(eval(input())) A, B = list(map(int, input().split())) while True: if A == B + 1: print('NG') break if A % K == 0: print('OK') break A += 1
11
11
196
196
K = int(eval(input())) A, B = list(map(int, input().split())) while True: if A % K == 0: print("OK") break A += 1 if A == B + 1: print("NG") break
K = int(eval(input())) A, B = list(map(int, input().split())) while True: if A == B + 1: print("NG") break if A % K == 0: print("OK") break A += 1
false
0
[ "+ if A == B + 1:", "+ print(\"NG\")", "+ break", "- if A == B + 1:", "- print(\"NG\")", "- break" ]
false
0.038841
0.040361
0.962338
[ "s162785949", "s363362861" ]
u343675824
p03722
python
s411569292
s767602971
575
378
50,264
47,320
Accepted
Accepted
34.26
N, M = list(map(int, input().split())) a, b, c = [0] * M, [0] * M, [0] * M d = [-1e20] * N for i in range(M): a[i], b[i], c[i] = list(map(int, input().split())) a[i] -= 1 b[i] -= 1 d[0] = 0 for i in range(N-1): for j in range(M): d[b[j]] = max((d[b[j]], d[a[j]] + c[j])) isCycle = False for i in range(N-1): if isCycle: break for j in range(M): if b[j] == N-1 and d[b[j]] < d[a[j]] + c[j]: isCycle = True break d[b[j]] = max((d[b[j]], d[a[j]] + c[j])) if isCycle: print('inf') else: print((d[N-1]))
N, M = list(map(int, input().split())) a, b, c = [None] * M, [None] * M, [None] * M INF = 1e14 d = [-INF] * N d[0] = 0 for i in range(M): a[i], b[i], c[i] = list(map(int, input().split())) a[i] -= 1 b[i] -= 1 for i in range(N): for j in range(M): if d[a[j]] + c[j] > d[b[j]]: d[b[j]] = d[a[j]] + c[j] ans = d[N-1] for i in range(N): for j in range(M): if d[a[j]] + c[j] > d[b[j]]: d[b[j]] = d[a[j]] + c[j] if ans != d[N-1]: print('inf') else: print(ans)
26
23
600
533
N, M = list(map(int, input().split())) a, b, c = [0] * M, [0] * M, [0] * M d = [-1e20] * N for i in range(M): a[i], b[i], c[i] = list(map(int, input().split())) a[i] -= 1 b[i] -= 1 d[0] = 0 for i in range(N - 1): for j in range(M): d[b[j]] = max((d[b[j]], d[a[j]] + c[j])) isCycle = False for i in range(N - 1): if isCycle: break for j in range(M): if b[j] == N - 1 and d[b[j]] < d[a[j]] + c[j]: isCycle = True break d[b[j]] = max((d[b[j]], d[a[j]] + c[j])) if isCycle: print("inf") else: print((d[N - 1]))
N, M = list(map(int, input().split())) a, b, c = [None] * M, [None] * M, [None] * M INF = 1e14 d = [-INF] * N d[0] = 0 for i in range(M): a[i], b[i], c[i] = list(map(int, input().split())) a[i] -= 1 b[i] -= 1 for i in range(N): for j in range(M): if d[a[j]] + c[j] > d[b[j]]: d[b[j]] = d[a[j]] + c[j] ans = d[N - 1] for i in range(N): for j in range(M): if d[a[j]] + c[j] > d[b[j]]: d[b[j]] = d[a[j]] + c[j] if ans != d[N - 1]: print("inf") else: print(ans)
false
11.538462
[ "-a, b, c = [0] * M, [0] * M, [0] * M", "-d = [-1e20] * N", "+a, b, c = [None] * M, [None] * M, [None] * M", "+INF = 1e14", "+d = [-INF] * N", "+d[0] = 0", "-d[0] = 0", "-for i in range(N - 1):", "+for i in range(N):", "- d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))", "-isCycle = False", "-for i in range(N - 1):", "- if isCycle:", "- break", "+ if d[a[j]] + c[j] > d[b[j]]:", "+ d[b[j]] = d[a[j]] + c[j]", "+ans = d[N - 1]", "+for i in range(N):", "- if b[j] == N - 1 and d[b[j]] < d[a[j]] + c[j]:", "- isCycle = True", "- break", "- d[b[j]] = max((d[b[j]], d[a[j]] + c[j]))", "-if isCycle:", "+ if d[a[j]] + c[j] > d[b[j]]:", "+ d[b[j]] = d[a[j]] + c[j]", "+if ans != d[N - 1]:", "- print((d[N - 1]))", "+ print(ans)" ]
false
0.090414
0.089116
1.014568
[ "s411569292", "s767602971" ]
u764600134
p03645
python
s963755946
s008199572
652
576
46,456
19,012
Accepted
Accepted
11.66
# -*- coding: utf-8 -*- """ http://abc068.contest.atcoder.jp/tasks/arc079_a """ def solve(routes, N): result = 'IMPOSSIBLE' to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 for f, t in routes: if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: result = 'POSSIBLE' return result def main(): N, M = list(map(int, input().split())) routes = [] for _ in range(M): routes.append([int(x) for x in input().split()]) result = solve(routes, N) print(result) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- """ http://abc068.contest.atcoder.jp/tasks/arc079_a AC """ def solve(routes, N): result = 'IMPOSSIBLE' to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 for f, t in routes: if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: result = 'POSSIBLE' return result def main(): N, M = list(map(int, input().split())) routes = [] for _ in range(M): routes.append([int(x) for x in input().split()]) result = solve(routes, N) print(result) if __name__ == '__main__': # main() to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 N, M = list(map(int, input().split())) for _ in range(M): f, t = list(map(int, input().split())) if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: print('POSSIBLE') else: print('IMPOSSIBLE')
33
50
697
1,117
# -*- coding: utf-8 -*- """ http://abc068.contest.atcoder.jp/tasks/arc079_a """ def solve(routes, N): result = "IMPOSSIBLE" to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 for f, t in routes: if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: result = "POSSIBLE" return result def main(): N, M = list(map(int, input().split())) routes = [] for _ in range(M): routes.append([int(x) for x in input().split()]) result = solve(routes, N) print(result) if __name__ == "__main__": main()
# -*- coding: utf-8 -*- """ http://abc068.contest.atcoder.jp/tasks/arc079_a AC """ def solve(routes, N): result = "IMPOSSIBLE" to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 for f, t in routes: if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: result = "POSSIBLE" return result def main(): N, M = list(map(int, input().split())) routes = [] for _ in range(M): routes.append([int(x) for x in input().split()]) result = solve(routes, N) print(result) if __name__ == "__main__": # main() to_middle = set() # 島1から渡ることのできる島 from_middle = set() # 島Nへ渡ることのできる島 N, M = list(map(int, input().split())) for _ in range(M): f, t = list(map(int, input().split())) if f == 1: to_middle.add(t) elif t == N: from_middle.add(f) if to_middle & from_middle: print("POSSIBLE") else: print("IMPOSSIBLE")
false
34
[ "+AC", "- main()", "+ # main()", "+ to_middle = set() # 島1から渡ることのできる島", "+ from_middle = set() # 島Nへ渡ることのできる島", "+ N, M = list(map(int, input().split()))", "+ for _ in range(M):", "+ f, t = list(map(int, input().split()))", "+ if f == 1:", "+ to_middle.add(t)", "+ elif t == N:", "+ from_middle.add(f)", "+ if to_middle & from_middle:", "+ print(\"POSSIBLE\")", "+ else:", "+ print(\"IMPOSSIBLE\")" ]
false
0.076573
0.087592
0.874206
[ "s963755946", "s008199572" ]
u316386814
p04011
python
s925823831
s039900512
149
17
12,468
2,940
Accepted
Accepted
88.59
import numpy as np from collections import Counter, defaultdict, deque n = int(eval(input())) k = int(eval(input())) x = int(eval(input())) y = int(eval(input())) if n <= k: ans = n * x else: ans = k * x + (n - k) * y print(ans)
n = int(eval(input())) k = int(eval(input())) x = int(eval(input())) y = int(eval(input())) if n <= k: ans = n * x else: ans = k * x + (n - k) * y print(ans)
14
12
228
155
import numpy as np from collections import Counter, defaultdict, deque n = int(eval(input())) k = int(eval(input())) x = int(eval(input())) y = int(eval(input())) if n <= k: ans = n * x else: ans = k * x + (n - k) * y print(ans)
n = int(eval(input())) k = int(eval(input())) x = int(eval(input())) y = int(eval(input())) if n <= k: ans = n * x else: ans = k * x + (n - k) * y print(ans)
false
14.285714
[ "-import numpy as np", "-from collections import Counter, defaultdict, deque", "-" ]
false
0.036681
0.124959
0.293547
[ "s925823831", "s039900512" ]
u592248346
p03290
python
s637223506
s480185736
173
128
3,064
9,160
Accepted
Accepted
26.01
# coding: utf-8 # Your code here! D,G = list(map(int,input().split())) p,c = [],[] res = 1<<30 for i in range(D): x,y = list(map(int,input().split())) p.append(x) c.append(y) for i in range(2**D): sum_x,cnt = 0,0 for j in range(D): if i&(1<<j): sum_x+=c[j]+p[j]*100*(j+1) cnt+=p[j] if(sum_x<=G): for j in reversed(list(range(D))): if i&(1<<j): continue for k in range(p[j]): if sum_x>=G: break sum_x+=100*(j+1) cnt+=1 if(res>cnt): res=cnt print(res)
d,g = list(map(int,input().split())) p,c = [],[] ans = float('inf') for i in range(d): x,y = list(map(int,input().split())) p.append(x) c.append(y) for i in range((1<<d)): tmp,cnt = 0,0 for j in range(d): if i&(1<<j): tmp = tmp + 100*(j+1)*p[j]+c[j] cnt += p[j] if tmp>=g: if cnt<ans: ans=cnt else: for j in range(d-1,-1,-1): if i&(1<<j): continue for k in range(p[j]): if tmp>=g: break tmp = tmp + 100*(j+1) cnt+=1 if cnt<ans: ans = cnt print(ans)
25
24
596
615
# coding: utf-8 # Your code here! D, G = list(map(int, input().split())) p, c = [], [] res = 1 << 30 for i in range(D): x, y = list(map(int, input().split())) p.append(x) c.append(y) for i in range(2**D): sum_x, cnt = 0, 0 for j in range(D): if i & (1 << j): sum_x += c[j] + p[j] * 100 * (j + 1) cnt += p[j] if sum_x <= G: for j in reversed(list(range(D))): if i & (1 << j): continue for k in range(p[j]): if sum_x >= G: break sum_x += 100 * (j + 1) cnt += 1 if res > cnt: res = cnt print(res)
d, g = list(map(int, input().split())) p, c = [], [] ans = float("inf") for i in range(d): x, y = list(map(int, input().split())) p.append(x) c.append(y) for i in range((1 << d)): tmp, cnt = 0, 0 for j in range(d): if i & (1 << j): tmp = tmp + 100 * (j + 1) * p[j] + c[j] cnt += p[j] if tmp >= g: if cnt < ans: ans = cnt else: for j in range(d - 1, -1, -1): if i & (1 << j): continue for k in range(p[j]): if tmp >= g: break tmp = tmp + 100 * (j + 1) cnt += 1 if cnt < ans: ans = cnt print(ans)
false
4
[ "-# coding: utf-8", "-# Your code here!", "-D, G = list(map(int, input().split()))", "+d, g = list(map(int, input().split()))", "-res = 1 << 30", "-for i in range(D):", "+ans = float(\"inf\")", "+for i in range(d):", "-for i in range(2**D):", "- sum_x, cnt = 0, 0", "- for j in range(D):", "+for i in range((1 << d)):", "+ tmp, cnt = 0, 0", "+ for j in range(d):", "- sum_x += c[j] + p[j] * 100 * (j + 1)", "+ tmp = tmp + 100 * (j + 1) * p[j] + c[j]", "- if sum_x <= G:", "- for j in reversed(list(range(D))):", "+ if tmp >= g:", "+ if cnt < ans:", "+ ans = cnt", "+ else:", "+ for j in range(d - 1, -1, -1):", "- if sum_x >= G:", "+ if tmp >= g:", "- sum_x += 100 * (j + 1)", "+ tmp = tmp + 100 * (j + 1)", "- if res > cnt:", "- res = cnt", "-print(res)", "+ if cnt < ans:", "+ ans = cnt", "+print(ans)" ]
false
0.044627
0.045666
0.977254
[ "s637223506", "s480185736" ]
u241159583
p02756
python
s308251647
s648485692
503
346
35,316
34,672
Accepted
Accepted
31.21
from collections import deque s = eval(input()) Q = int(eval(input())) q = [list(input().split()) for _ in range(Q)] ans = deque(s) ok = True for v in q: if v[0] == "1": if ok: ok = False else: ok = True else: if v[1] == "1": if ok: ans.appendleft(v[2]) else: ans.append(v[2]) else: if ok: ans.append(v[2]) else: ans.appendleft(v[2]) ans = list(ans) if not ok: ans = ans[::-1] print(("".join(ans)))
from collections import deque s = eval(input()) q = int(eval(input())) Q = [list(input().split()) for _ in range(q)] ans = deque(s) ok = True for v in Q: if v[0] == "1": if ok: ok = False else: ok = True else: if v[1] == "1": if ok: ans.appendleft(v[2]) else: ans.append(v[2]) else: if ok: ans.append(v[2]) else: ans.appendleft(v[2]) ans = list(ans) if not ok: ans = ans[::-1] print(("".join(ans)))
22
21
452
493
from collections import deque s = eval(input()) Q = int(eval(input())) q = [list(input().split()) for _ in range(Q)] ans = deque(s) ok = True for v in q: if v[0] == "1": if ok: ok = False else: ok = True else: if v[1] == "1": if ok: ans.appendleft(v[2]) else: ans.append(v[2]) else: if ok: ans.append(v[2]) else: ans.appendleft(v[2]) ans = list(ans) if not ok: ans = ans[::-1] print(("".join(ans)))
from collections import deque s = eval(input()) q = int(eval(input())) Q = [list(input().split()) for _ in range(q)] ans = deque(s) ok = True for v in Q: if v[0] == "1": if ok: ok = False else: ok = True else: if v[1] == "1": if ok: ans.appendleft(v[2]) else: ans.append(v[2]) else: if ok: ans.append(v[2]) else: ans.appendleft(v[2]) ans = list(ans) if not ok: ans = ans[::-1] print(("".join(ans)))
false
4.545455
[ "-Q = int(eval(input()))", "-q = [list(input().split()) for _ in range(Q)]", "+q = int(eval(input()))", "+Q = [list(input().split()) for _ in range(q)]", "-for v in q:", "+for v in Q:" ]
false
0.03669
0.035509
1.033259
[ "s308251647", "s648485692" ]
u761989513
p03489
python
s109625704
s612505556
109
92
21,228
18,672
Accepted
Accepted
15.6
import collections n = int(eval(input())) a = collections.Counter(list(map(int, input().split()))).most_common() ans = 0 for i, j in a: if i > j: ans += j if i < j: ans += j - i print(ans)
import collections n = int(eval(input())) a = list(map(int, input().split())) ac = collections.Counter(a) ans = 0 for i in list(ac.items()): if i[0] != i[1]: if i[1] > i[0]: ans += i[1] - i[0] else: ans += i[1] print(ans)
11
13
218
266
import collections n = int(eval(input())) a = collections.Counter(list(map(int, input().split()))).most_common() ans = 0 for i, j in a: if i > j: ans += j if i < j: ans += j - i print(ans)
import collections n = int(eval(input())) a = list(map(int, input().split())) ac = collections.Counter(a) ans = 0 for i in list(ac.items()): if i[0] != i[1]: if i[1] > i[0]: ans += i[1] - i[0] else: ans += i[1] print(ans)
false
15.384615
[ "-a = collections.Counter(list(map(int, input().split()))).most_common()", "+a = list(map(int, input().split()))", "+ac = collections.Counter(a)", "-for i, j in a:", "- if i > j:", "- ans += j", "- if i < j:", "- ans += j - i", "+for i in list(ac.items()):", "+ if i[0] != i[1]:", "+ if i[1] > i[0]:", "+ ans += i[1] - i[0]", "+ else:", "+ ans += i[1]" ]
false
0.037864
0.037266
1.016029
[ "s109625704", "s612505556" ]
u645250356
p02820
python
s398725643
s413414416
389
105
82,008
6,136
Accepted
Accepted
73.01
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,pprint,fractions sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n,k = inpl() R,S,P = inpl() a = eval(input()) res = 0 for rem in range(k): dp = [[0]*3 for _ in range(len(list(range(rem,n,k)))+1)] for i,j in enumerate(range(rem,n,k)): for x in range(3): pls = 0 if x == 0 and a[j] == 's': pls += R if x == 1 and a[j] == 'p': pls += S if x == 2 and a[j] == 'r': pls += P for y in range(3): if x == y: continue dp[i+1][x] = max(dp[i][y]+pls, dp[i+1][x]) # print(dp) res += max(dp[-1]) print(res)
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,copy sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n,k = inpl() R,S,P = inpl() t = list(eval(input())) di = {'r':P, 's':R, 'p':S} res = 0 ch = True for i in range(k): for j in range(i,n,k): if j > i and t[j] == t[j-k] and ch: ch = False continue res += di[t[j]] ch = True # print(i,j) # print(res) print(res)
30
25
923
655
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, pprint, fractions sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n, k = inpl() R, S, P = inpl() a = eval(input()) res = 0 for rem in range(k): dp = [[0] * 3 for _ in range(len(list(range(rem, n, k))) + 1)] for i, j in enumerate(range(rem, n, k)): for x in range(3): pls = 0 if x == 0 and a[j] == "s": pls += R if x == 1 and a[j] == "p": pls += S if x == 2 and a[j] == "r": pls += P for y in range(3): if x == y: continue dp[i + 1][x] = max(dp[i][y] + pls, dp[i + 1][x]) # print(dp) res += max(dp[-1]) print(res)
from collections import Counter, defaultdict, deque from heapq import heappop, heappush, heapify import sys, bisect, math, itertools, fractions, copy sys.setrecursionlimit(10**8) mod = 10**9 + 7 INF = float("inf") def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) n, k = inpl() R, S, P = inpl() t = list(eval(input())) di = {"r": P, "s": R, "p": S} res = 0 ch = True for i in range(k): for j in range(i, n, k): if j > i and t[j] == t[j - k] and ch: ch = False continue res += di[t[j]] ch = True # print(i,j) # print(res) print(res)
false
16.666667
[ "-import sys, bisect, math, itertools, pprint, fractions", "+import sys, bisect, math, itertools, fractions, copy", "-a = eval(input())", "+t = list(eval(input()))", "+di = {\"r\": P, \"s\": R, \"p\": S}", "-for rem in range(k):", "- dp = [[0] * 3 for _ in range(len(list(range(rem, n, k))) + 1)]", "- for i, j in enumerate(range(rem, n, k)):", "- for x in range(3):", "- pls = 0", "- if x == 0 and a[j] == \"s\":", "- pls += R", "- if x == 1 and a[j] == \"p\":", "- pls += S", "- if x == 2 and a[j] == \"r\":", "- pls += P", "- for y in range(3):", "- if x == y:", "- continue", "- dp[i + 1][x] = max(dp[i][y] + pls, dp[i + 1][x])", "- # print(dp)", "- res += max(dp[-1])", "+ch = True", "+for i in range(k):", "+ for j in range(i, n, k):", "+ if j > i and t[j] == t[j - k] and ch:", "+ ch = False", "+ continue", "+ res += di[t[j]]", "+ ch = True", "+ # print(i,j)", "+ # print(res)" ]
false
0.0739
0.046443
1.591187
[ "s398725643", "s413414416" ]
u562935282
p03171
python
s948435516
s694228391
530
330
179,804
111,964
Accepted
Accepted
37.74
def solve(): n = int(eval(input())) a = tuple(int(x) for x in input().split()) memo = tuple([None] * n for _ in range(n)) for i in range(n): memo[i][i] = a[i] for l in range(n - 2, -1, -1): for r in range(l + 1, n): memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r]) print((memo[0][n - 1])) if __name__ == '__main__': solve() # [l,r]を # l:=配列aの右端から左にシフト # r:=lと一致する位置からn-1まで右にシフト # と考えると、l==rは既にメモ化済みなので、l=n-2以前、r=l+1以降を調べればよい # 漸化式で使う値は、 # lがより右にいるときの計算結果(前のループで計算済み)と # rがより左にいるときの計算結果(一番左でもl==rなので計算済み) # なので、参照する値がNoneになることはなく、Noneのチェックは不要になる # enumerateを辞めた
n = int(eval(input())) a = list(map(int, input().split())) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = a[i] for i in range(n - 2, -1, -1): for j in range(i + 1, n): dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]) print((dp[0][n - 1])) # 下記提出と全く同じ内容で提出します # https://atcoder.jp/contests/dp/submissions/6590284 # これまでの連投で参考にしていたコード # ほぼ同じ内容で提出しているつもりなのに、速度差が一向に縮まらない # maxの引数の順番が自分と違うのが速度差の原因?
28
19
657
450
def solve(): n = int(eval(input())) a = tuple(int(x) for x in input().split()) memo = tuple([None] * n for _ in range(n)) for i in range(n): memo[i][i] = a[i] for l in range(n - 2, -1, -1): for r in range(l + 1, n): memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r]) print((memo[0][n - 1])) if __name__ == "__main__": solve() # [l,r]を # l:=配列aの右端から左にシフト # r:=lと一致する位置からn-1まで右にシフト # と考えると、l==rは既にメモ化済みなので、l=n-2以前、r=l+1以降を調べればよい # 漸化式で使う値は、 # lがより右にいるときの計算結果(前のループで計算済み)と # rがより左にいるときの計算結果(一番左でもl==rなので計算済み) # なので、参照する値がNoneになることはなく、Noneのチェックは不要になる # enumerateを辞めた
n = int(eval(input())) a = list(map(int, input().split())) dp = [[0] * n for _ in range(n)] for i in range(n): dp[i][i] = a[i] for i in range(n - 2, -1, -1): for j in range(i + 1, n): dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1]) print((dp[0][n - 1])) # 下記提出と全く同じ内容で提出します # https://atcoder.jp/contests/dp/submissions/6590284 # これまでの連投で参考にしていたコード # ほぼ同じ内容で提出しているつもりなのに、速度差が一向に縮まらない # maxの引数の順番が自分と違うのが速度差の原因?
false
32.142857
[ "-def solve():", "- n = int(eval(input()))", "- a = tuple(int(x) for x in input().split())", "- memo = tuple([None] * n for _ in range(n))", "- for i in range(n):", "- memo[i][i] = a[i]", "- for l in range(n - 2, -1, -1):", "- for r in range(l + 1, n):", "- memo[l][r] = max(a[r] - memo[l][r - 1], a[l] - memo[l + 1][r])", "- print((memo[0][n - 1]))", "-", "-", "-if __name__ == \"__main__\":", "- solve()", "-# [l,r]を", "-# l:=配列aの右端から左にシフト", "-# r:=lと一致する位置からn-1まで右にシフト", "-# と考えると、l==rは既にメモ化済みなので、l=n-2以前、r=l+1以降を調べればよい", "-# 漸化式で使う値は、", "-# lがより右にいるときの計算結果(前のループで計算済み)と", "-# rがより左にいるときの計算結果(一番左でもl==rなので計算済み)", "-# なので、参照する値がNoneになることはなく、Noneのチェックは不要になる", "-# enumerateを辞めた", "+n = int(eval(input()))", "+a = list(map(int, input().split()))", "+dp = [[0] * n for _ in range(n)]", "+for i in range(n):", "+ dp[i][i] = a[i]", "+for i in range(n - 2, -1, -1):", "+ for j in range(i + 1, n):", "+ dp[i][j] = max(a[i] - dp[i + 1][j], a[j] - dp[i][j - 1])", "+print((dp[0][n - 1]))", "+# 下記提出と全く同じ内容で提出します", "+# https://atcoder.jp/contests/dp/submissions/6590284", "+# これまでの連投で参考にしていたコード", "+# ほぼ同じ内容で提出しているつもりなのに、速度差が一向に縮まらない", "+# maxの引数の順番が自分と違うのが速度差の原因?" ]
false
0.036463
0.037127
0.982122
[ "s948435516", "s694228391" ]
u729133443
p03292
python
s739379111
s792258004
177
18
38,256
2,940
Accepted
Accepted
89.83
a,_,b=sorted(map(int,input().split()));print((b-a))
*a,=list(map(int,input().split()));print((max(a)-min(a)))
1
1
49
49
a, _, b = sorted(map(int, input().split())) print((b - a))
(*a,) = list(map(int, input().split())) print((max(a) - min(a)))
false
0
[ "-a, _, b = sorted(map(int, input().split()))", "-print((b - a))", "+(*a,) = list(map(int, input().split()))", "+print((max(a) - min(a)))" ]
false
0.047702
0.040751
1.170557
[ "s739379111", "s792258004" ]
u150984829
p02380
python
s166469027
s610446793
30
20
5,720
5,720
Accepted
Accepted
33.33
from math import * a,b,C=map(int,input().split()) C=C*pi/180 S=a*b*sin(C)/2 print(S,a+b+(a*a+b*b-2*a*b*cos(C))**0.5,2*S/a,sep='\n')
import math a,b,C=map(int,input().split()) C=C*math.pi/180 S=a*b*math.sin(C)/2 print(S,a+b+(a*a+b*b-2*a*b*math.cos(C))**0.5,2*S/a,sep='\n')
5
5
135
143
from math import * a, b, C = map(int, input().split()) C = C * pi / 180 S = a * b * sin(C) / 2 print(S, a + b + (a * a + b * b - 2 * a * b * cos(C)) ** 0.5, 2 * S / a, sep="\n")
import math a, b, C = map(int, input().split()) C = C * math.pi / 180 S = a * b * math.sin(C) / 2 print(S, a + b + (a * a + b * b - 2 * a * b * math.cos(C)) ** 0.5, 2 * S / a, sep="\n")
false
0
[ "-from math import *", "+import math", "-C = C * pi / 180", "-S = a * b * sin(C) / 2", "-print(S, a + b + (a * a + b * b - 2 * a * b * cos(C)) ** 0.5, 2 * S / a, sep=\"\\n\")", "+C = C * math.pi / 180", "+S = a * b * math.sin(C) / 2", "+print(S, a + b + (a * a + b * b - 2 * a * b * math.cos(C)) ** 0.5, 2 * S / a, sep=\"\\n\")" ]
false
0.038121
0.129157
0.295152
[ "s166469027", "s610446793" ]
u952708174
p03073
python
s483755966
s056504591
37
18
4,212
3,188
Accepted
Accepted
51.35
def c_coloring_colorfully(S): s1 = '10' * (len(S) // 2) + ('1' if len(S) % 2 == 1 else '') s2 = '01' * (len(S) // 2) + ('0' if len(S) % 2 == 1 else '') ans1 = len([1 for k, s in enumerate(S) if s != s1[k]]) ans2 = len([1 for k, s in enumerate(S) if s != s2[k]]) return min(ans1, ans2) S = eval(input()) print((c_coloring_colorfully(S)))
def c_coloring_colorfully(S): ans1 = S[::2].count('0') + S[1::2].count('1') # 1010...と一致しない数字の数 ans2 = S[::2].count('1') + S[1::2].count('0') # 0101...と一致しない数字の数 return min(ans1, ans2) S = eval(input()) print((c_coloring_colorfully(S)))
9
7
357
249
def c_coloring_colorfully(S): s1 = "10" * (len(S) // 2) + ("1" if len(S) % 2 == 1 else "") s2 = "01" * (len(S) // 2) + ("0" if len(S) % 2 == 1 else "") ans1 = len([1 for k, s in enumerate(S) if s != s1[k]]) ans2 = len([1 for k, s in enumerate(S) if s != s2[k]]) return min(ans1, ans2) S = eval(input()) print((c_coloring_colorfully(S)))
def c_coloring_colorfully(S): ans1 = S[::2].count("0") + S[1::2].count("1") # 1010...と一致しない数字の数 ans2 = S[::2].count("1") + S[1::2].count("0") # 0101...と一致しない数字の数 return min(ans1, ans2) S = eval(input()) print((c_coloring_colorfully(S)))
false
22.222222
[ "- s1 = \"10\" * (len(S) // 2) + (\"1\" if len(S) % 2 == 1 else \"\")", "- s2 = \"01\" * (len(S) // 2) + (\"0\" if len(S) % 2 == 1 else \"\")", "- ans1 = len([1 for k, s in enumerate(S) if s != s1[k]])", "- ans2 = len([1 for k, s in enumerate(S) if s != s2[k]])", "+ ans1 = S[::2].count(\"0\") + S[1::2].count(\"1\") # 1010...と一致しない数字の数", "+ ans2 = S[::2].count(\"1\") + S[1::2].count(\"0\") # 0101...と一致しない数字の数" ]
false
0.041156
0.035931
1.145435
[ "s483755966", "s056504591" ]
u327466606
p03702
python
s304243282
s648762992
1,174
742
7,072
7,072
Accepted
Accepted
36.8
N,A,B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] low = sum(H)//(len(H)*B+A-B) - 1 high = max(H)//B+1 d = A-B ceildiv = lambda x,y: -(-x//y) while low + 1 < high: mid = (low+high)//2 offset = mid*B cnt = sum(max(ceildiv(h - offset, d),0) for h in H) if cnt > mid: low = mid else: high = mid print(high)
N,A,B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] d = A-B temp = max(H) low = temp//A - 1 high = temp//B+1 while low + 1 < high: mid = (low+high)//2 offset = mid*B cnt = -sum((offset-h)//d for h in H if h > offset) if cnt > mid: low = mid else: high = mid print(high)
20
20
365
330
N, A, B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] low = sum(H) // (len(H) * B + A - B) - 1 high = max(H) // B + 1 d = A - B ceildiv = lambda x, y: -(-x // y) while low + 1 < high: mid = (low + high) // 2 offset = mid * B cnt = sum(max(ceildiv(h - offset, d), 0) for h in H) if cnt > mid: low = mid else: high = mid print(high)
N, A, B = list(map(int, input().split())) H = [int(eval(input())) for i in range(N)] d = A - B temp = max(H) low = temp // A - 1 high = temp // B + 1 while low + 1 < high: mid = (low + high) // 2 offset = mid * B cnt = -sum((offset - h) // d for h in H if h > offset) if cnt > mid: low = mid else: high = mid print(high)
false
0
[ "-low = sum(H) // (len(H) * B + A - B) - 1", "-high = max(H) // B + 1", "-ceildiv = lambda x, y: -(-x // y)", "+temp = max(H)", "+low = temp // A - 1", "+high = temp // B + 1", "- cnt = sum(max(ceildiv(h - offset, d), 0) for h in H)", "+ cnt = -sum((offset - h) // d for h in H if h > offset)" ]
false
0.046219
0.046958
0.984266
[ "s304243282", "s648762992" ]
u648868410
p02588
python
s433611733
s878303811
1,433
405
26,976
77,840
Accepted
Accepted
71.74
import numpy as np N=int(eval(input())) A=[] PRECISION_DIGITS=9 NO_ENTRY = 0 ARR_SIZE=PRECISION_DIGITS*2+1 cnt=np.full((ARR_SIZE,ARR_SIZE),NO_ENTRY,int) # cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int) # print(cnt) for n in range(N): tmpA = float(eval(input())) tmpA = round(tmpA*10**PRECISION_DIGITS) #print(tmpA) five = 0 two = 0 # (10**9) -> (two,five)=(9,9) # min = 10**-9, ignore < 10**9 ??? while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2: two += 1 tmpA //= 2 while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2: five += 1 tmpA //= 5 if cnt[two][five] == NO_ENTRY: cnt[two][five]=1 else: cnt[two][five]+=1 # print(cnt) ans = 0 for x1 in range(ARR_SIZE): for y1 in range(ARR_SIZE): if cnt[x1][y1] == NO_ENTRY: continue for x2 in range(x1,ARR_SIZE): for y2 in range(ARR_SIZE): if cnt[x2][y2] == NO_ENTRY: continue # 2**a(a>=0) and 5**b(b>=0) => integer if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2: if x1 == x2 and y1 == y2: # same entry # Total number of combinations choose 2 items # nC2 = n*(n-1)/2 ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2) else: ans += int(cnt[x1][y1]*cnt[x2][y2]) # completed counted up entry cnt[x1][y1] = NO_ENTRY print(ans)
import collections N=int(eval(input())) A=[] PRECISION_DIGITS=9 cnt=collections.defaultdict(int) for n in range(N): tmpA = float(eval(input())) tmpA = round(tmpA*10**PRECISION_DIGITS) #print(tmpA) five = 0 two = 0 while (tmpA % 2) == 0: two += 1 tmpA //= 2 while (tmpA % 5) == 0: five += 1 tmpA //= 5 # (10**9) -> (two,five)=(9,9) two -= PRECISION_DIGITS five -= PRECISION_DIGITS cnt[(two,five)]+=1 # print(cnt) ans = 0 for t1, cnt1 in list(cnt.items()): for t2, cnt2 in list(cnt.items()): # 2**a(a>=0) and 5**b(b>=0) => integer if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]: if t1 < t2: ans += int(cnt1*cnt2) elif t1 == t2: # same entry # Total number of combinations choose 2 items # nC2 = n*(n-1)/2 ans += int((cnt1*(cnt2-1))/2) print(ans)
60
45
1,348
818
import numpy as np N = int(eval(input())) A = [] PRECISION_DIGITS = 9 NO_ENTRY = 0 ARR_SIZE = PRECISION_DIGITS * 2 + 1 cnt = np.full((ARR_SIZE, ARR_SIZE), NO_ENTRY, int) # cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int) # print(cnt) for n in range(N): tmpA = float(eval(input())) tmpA = round(tmpA * 10**PRECISION_DIGITS) # print(tmpA) five = 0 two = 0 # (10**9) -> (two,five)=(9,9) # min = 10**-9, ignore < 10**9 ??? while (tmpA % 2) == 0 and two < PRECISION_DIGITS * 2: two += 1 tmpA //= 2 while (tmpA % 5) == 0 and five < PRECISION_DIGITS * 2: five += 1 tmpA //= 5 if cnt[two][five] == NO_ENTRY: cnt[two][five] = 1 else: cnt[two][five] += 1 # print(cnt) ans = 0 for x1 in range(ARR_SIZE): for y1 in range(ARR_SIZE): if cnt[x1][y1] == NO_ENTRY: continue for x2 in range(x1, ARR_SIZE): for y2 in range(ARR_SIZE): if cnt[x2][y2] == NO_ENTRY: continue # 2**a(a>=0) and 5**b(b>=0) => integer if ( 0 <= x1 + x2 - PRECISION_DIGITS * 2 and 0 <= y1 + y2 - PRECISION_DIGITS * 2 ): if x1 == x2 and y1 == y2: # same entry # Total number of combinations choose 2 items # nC2 = n*(n-1)/2 ans += int((cnt[x1][y1] * (cnt[x2][y2] - 1)) // 2) else: ans += int(cnt[x1][y1] * cnt[x2][y2]) # completed counted up entry cnt[x1][y1] = NO_ENTRY print(ans)
import collections N = int(eval(input())) A = [] PRECISION_DIGITS = 9 cnt = collections.defaultdict(int) for n in range(N): tmpA = float(eval(input())) tmpA = round(tmpA * 10**PRECISION_DIGITS) # print(tmpA) five = 0 two = 0 while (tmpA % 2) == 0: two += 1 tmpA //= 2 while (tmpA % 5) == 0: five += 1 tmpA //= 5 # (10**9) -> (two,five)=(9,9) two -= PRECISION_DIGITS five -= PRECISION_DIGITS cnt[(two, five)] += 1 # print(cnt) ans = 0 for t1, cnt1 in list(cnt.items()): for t2, cnt2 in list(cnt.items()): # 2**a(a>=0) and 5**b(b>=0) => integer if 0 <= t1[0] + t2[0] and 0 <= t1[1] + t2[1]: if t1 < t2: ans += int(cnt1 * cnt2) elif t1 == t2: # same entry # Total number of combinations choose 2 items # nC2 = n*(n-1)/2 ans += int((cnt1 * (cnt2 - 1)) / 2) print(ans)
false
25
[ "-import numpy as np", "+import collections", "-NO_ENTRY = 0", "-ARR_SIZE = PRECISION_DIGITS * 2 + 1", "-cnt = np.full((ARR_SIZE, ARR_SIZE), NO_ENTRY, int)", "-# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)", "-# print(cnt)", "+cnt = collections.defaultdict(int)", "- # (10**9) -> (two,five)=(9,9)", "- # min = 10**-9, ignore < 10**9 ???", "- while (tmpA % 2) == 0 and two < PRECISION_DIGITS * 2:", "+ while (tmpA % 2) == 0:", "- while (tmpA % 5) == 0 and five < PRECISION_DIGITS * 2:", "+ while (tmpA % 5) == 0:", "- if cnt[two][five] == NO_ENTRY:", "- cnt[two][five] = 1", "- else:", "- cnt[two][five] += 1", "+ # (10**9) -> (two,five)=(9,9)", "+ two -= PRECISION_DIGITS", "+ five -= PRECISION_DIGITS", "+ cnt[(two, five)] += 1", "-for x1 in range(ARR_SIZE):", "- for y1 in range(ARR_SIZE):", "- if cnt[x1][y1] == NO_ENTRY:", "- continue", "- for x2 in range(x1, ARR_SIZE):", "- for y2 in range(ARR_SIZE):", "- if cnt[x2][y2] == NO_ENTRY:", "- continue", "- # 2**a(a>=0) and 5**b(b>=0) => integer", "- if (", "- 0 <= x1 + x2 - PRECISION_DIGITS * 2", "- and 0 <= y1 + y2 - PRECISION_DIGITS * 2", "- ):", "- if x1 == x2 and y1 == y2:", "- # same entry", "- # Total number of combinations choose 2 items", "- # nC2 = n*(n-1)/2", "- ans += int((cnt[x1][y1] * (cnt[x2][y2] - 1)) // 2)", "- else:", "- ans += int(cnt[x1][y1] * cnt[x2][y2])", "- # completed counted up entry", "- cnt[x1][y1] = NO_ENTRY", "+for t1, cnt1 in list(cnt.items()):", "+ for t2, cnt2 in list(cnt.items()):", "+ # 2**a(a>=0) and 5**b(b>=0) => integer", "+ if 0 <= t1[0] + t2[0] and 0 <= t1[1] + t2[1]:", "+ if t1 < t2:", "+ ans += int(cnt1 * cnt2)", "+ elif t1 == t2:", "+ # same entry", "+ # Total number of combinations choose 2 items", "+ # nC2 = n*(n-1)/2", "+ ans += int((cnt1 * (cnt2 - 1)) / 2)" ]
false
0.492132
0.040211
12.238808
[ "s433611733", "s878303811" ]
u347600233
p02712
python
s061423063
s586663143
154
103
9,104
34,432
Accepted
Accepted
33.12
n = int(eval(input())) sum = 0 for i in range(1, n + 1): if i % 3 != 0 and i % 5 != 0: sum += i print(sum)
# maspy 入力input() ver. import numpy as np n = int(eval(input())) x = np.arange(n + 1, dtype=np.int64) x[::3] = 0 x[::5] = 0 print((x.sum()))
6
7
117
138
n = int(eval(input())) sum = 0 for i in range(1, n + 1): if i % 3 != 0 and i % 5 != 0: sum += i print(sum)
# maspy 入力input() ver. import numpy as np n = int(eval(input())) x = np.arange(n + 1, dtype=np.int64) x[::3] = 0 x[::5] = 0 print((x.sum()))
false
14.285714
[ "+# maspy 入力input() ver.", "+import numpy as np", "+", "-sum = 0", "-for i in range(1, n + 1):", "- if i % 3 != 0 and i % 5 != 0:", "- sum += i", "-print(sum)", "+x = np.arange(n + 1, dtype=np.int64)", "+x[::3] = 0", "+x[::5] = 0", "+print((x.sum()))" ]
false
0.24732
0.335607
0.736933
[ "s061423063", "s586663143" ]