s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s941265587 | p03665 | u626891113 | 1595215240 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74840 | 487 | from scipy.special import comb
n, p = map(int, input().split())
a = list(map(int, input().split()))
ev, od = 0, 0
for i in a:
if i%2 == 0:
ev += 1
else:
od += 1
ans = 0
if p == 0:
for i in range(0, od+1, 2):
for j in range(ev+1):
ans += comb(od, i, exact = True)*comb(ev, ... |
s041727966 | p03665 | u811612390 | 1593782012 | Python | PyPy3 (7.3.0) | py | Runtime Error | 198 | 74544 | 241 | N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = 0
for a in A:
if a % 2 != 0:
odd += 1
if odd == 0
if P == 1:
res = 0
else:
res = 2 ** N
else:
res = 2 ** (N - 1)
print(res) |
s600198290 | p03665 | u277429554 | 1593407908 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9148 | 236 | n, p = map(int,input().split())
a = list(map(int,input().split()))
o = 0
for i in a:
if i % 2:
o += 1
e = n-o
if o != 0:
print((2**e)*int(2**(o-1)))
else:
if P == 0:
print(2**n)
else:
print(0) |
s944809061 | p03665 | u877283726 | 1593233550 | Python | Python (3.8.2) | py | Runtime Error | 31 | 9256 | 672 | import math
N,P = map(int,input().split())
A = list(map(int,input().split()))
pascal_triangle = []
memo = [[0 for _ in range(50)] for _ in range(50)]
def c(n,k):
if memo[n][k] != 0:
return memo[n][k]
if(k<=0 or n<=k):
memo[n][k] = 1
return 1
else:
ans = c(n-1, k-1) + c(n-1, k)
mem... |
s046516132 | p03665 | u708255304 | 1592501168 | Python | PyPy3 (2.4.0) | py | Runtime Error | 282 | 63088 | 1922 | # 二項係数を"やるだけ"にしてくれるライブラリ
from collections import Counter
MAX = 1000005
MOD = 10**9+7
factrial = [0]*MAX
inverse = [0]*MAX
factrial_inverse = [0]*MAX
# テーブルを作る前処理
def COMinit():
global factrial, inverse, factrial_inverse
factrial[0] = 1
factrial[1] = 1
inverse[1] = 1
factrial_inverse[0] = 1
fac... |
s480696390 | p03665 | u729294108 | 1591328951 | Python | Python (3.4.3) | py | Runtime Error | 330 | 23188 | 1686 | from scipy.special import comb
n, p = map(int, input().strip().split())
as_ = list(map(int, input().strip().split()))
num_evens = len([a for a in as_ if a % 2 == 0])
num_odds = len([a for a in as_ if a % 2 == 1])
counts = 0
if p == 0:
# 全部で偶数枚食べる = 偶数枚の袋 a 個 + 奇数枚の袋 b = 2k 個
# 0袋食べる場合も OK.
counts += 1
... |
s228408664 | p03665 | u614181788 | 1590957880 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 477 | n,p = map(int,input().split())
a = list(map(int,input().split()))
s = [0]*n
for i in range(n):
if a[i]%2 == 0:
s[i] = 0
else:
s[i] = 1
import collections
c = collections.Counter(s)
odd = c[1]
even = c[0]
x = 0
i = 0
while 2*i+p <= even:
x += comb(even, i, exact=True)
i += 1
from scipy... |
s951221513 | p03665 | u489124637 | 1590873063 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38384 | 666 | N, P = map(int,input().split())
A = list(map(int,input().split()))
even = 0
odd = 0
for i in A:
if i % 2 == 0:
even += 1
else:
odd += 1
#print(even,odd)
import math
def Perm(n, r):
return math.factorial(n)//math.factorial(n-r)
def comb(n, r):
return Perm(n, r)//math.factorial(r)
#prin... |
s008214833 | p03665 | u860002137 | 1590030470 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 659 | from collections import deque
nCr = {}
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
return nCr[(n, r)]
N, P = map(int, input().split())
A = np.array(list(map(int, input().s... |
s923376791 | p03665 | u860002137 | 1590030442 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3564 | 716 | from collections import deque
from functools import lru_cache
nCr = {}
@lru_cache(maxsize=None)
def cmb(n, r):
if r == 0 or r == n:
return 1
if r == 1:
return n
if (n, r) in nCr:
return nCr[(n, r)]
nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
return nCr[(n, r)]
N, P = map(i... |
s507996956 | p03665 | u860002137 | 1590030185 | Python | Python (3.4.3) | py | Runtime Error | 189 | 14512 | 483 | from scipy.special import comb
from collections import deque
N, P = map(int, input().split())
A = np.array(list(map(int, input().split())))
li = list(np.mod(A, 2))
zero = li.count(0)
one = li.count(1)
if P == 0:
combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]
if P == 1:
combi = [1] + [2 * x + 1 for x... |
s341197832 | p03665 | u694649864 | 1589598324 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 939 | #3問目
import itertools
def combinations_count(n, r):
return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
N, P = map(int, input().split())
A = list(map(int, input().split()))
#偶数グループと奇数グループにわける
odd = []
even = []
c = 0
for i in A:
if i % 2 == 0:
even.append(i)
else:
odd.a... |
s656226410 | p03665 | u948522631 | 1589150483 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 516 | import math
n, p = map(int,input().split())
a = list(map(int,input().split()))
even=0
odd=0
for i in a:
if i%2 == 0:
even+=1
else:
odd+=1
ans = 0
if p == 0:
ans += 1<<even
i = 2
while(i <= odd):
ans += math.comb(odd, i)
i+=2
print(ans)
else:
evens = 0
i... |
s667976258 | p03665 | u572012241 | 1588900371 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 260 | n, p = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
even = 0
for i in a:
if a %2 ==0:
even +=1
else:
odd+=1
if even == n:
if p == 0:
print(2**n)
else:
print(0)
else:
print(2**(n-1)) |
s815927719 | p03665 | u572012241 | 1588900348 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 259 | n, p = map(int, input().split())
a = list(map(int, input().split())
odd = 0
even = 0
for i in a:
if a %2 ==0:
even +=1
else:
odd+=1
if even == n:
if p == 0:
print(2**n)
else:
print(0)
else:
print(2**(n-1)) |
s203930127 | p03665 | u371385198 | 1588545014 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 344 |
import sys
input = sys.stdin.readline
def readstr():
return input().strip()
def readint():
return int(input())
def readnums():
return map(int, input().split())
def readstrs():
return input().split()
N, P = readnums()
A = map(lambda x: x % 2, readnums())
if not sum(A):
print(0)
else:... |
s615371882 | p03665 | u106778233 | 1588365156 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 161 | odds=sum(A)
evens=N-odds
if odds>0:
ans=2**evens
ans*=2**(odds-1)
print(ans)
else:
if P==0:
print(2**evens)
else:
print(0)
|
s046033646 | p03665 | u156815136 | 1588162248 | Python | PyPy3 (2.4.0) | py | Runtime Error | 176 | 38256 | 882 | from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
# d = m - k[i] - k[j]
# ... |
s578014510 | p03665 | u060793972 | 1587943299 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 385 | import math
def AGC017C(a,f):
p=0
for i in range(f,a,2):
p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)
return p
n,p=map(int,input().split())
d={1:0,0:0}
a=list(map(int,input().split()))
for i in a:
d[i%2]+=1
if p==0:
print((2**d[0])*AGC017C(d[1]),0)
else:
if d[1]==0:
... |
s974725487 | p03665 | u060793972 | 1587943252 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 414 | import math
def AGC017C(a,f):
p=0
for i in range(f,a,2):
p+=math.factorial(a)//math.factorial(a-i)//math.factorial(i)
return p
n,p=map(int,input().split())
d={1:0,0:0}
a=list(map(int,input().split()))
for i in a:
d[i%2]+=1
print(d)
print(AGC017C(2,0))
if p==0:
print((2**d[0])*AGC017C(d[1]),... |
s611436438 | p03665 | u691018832 | 1585851356 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 377 | import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
n, p, *a = map(int, read().split())
cnt_1 = 0
cnt_2 = 0
for i in a:
if a[i] % 2 == 1:
cnt_1 += 1
else:
cnt_2 += 1
ans = 2 ** max(0, cnt_1 - 1) * 2 *... |
s371850444 | p03665 | u022979415 | 1584726082 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 432 | def n_pow(a, n):
if n <= 0:
return 0
return pow(a, n)
def main():
bags, remainder = map(int, input().split())
biscuits = list(map(int, input().split()))
count = [0, 0]
for b in biscuits:
count[b % 2] += 1
if remainder == 0:
print(n_pow(2, count[0]) + n_pow(2, count[... |
s734121416 | p03665 | u102242691 | 1583978610 | Python | PyPy3 (2.4.0) | py | Runtime Error | 183 | 39280 | 212 |
n = int(input())
a = list(map(int,input().split()))
ans = 0
b = []
for i in range(n):
for j in range(i+1,n+1):
b = a[i:j]
# print(b)
if sum(b) == 0:
ans += 1
print(ans)
|
s802824793 | p03665 | u672475305 | 1583263386 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 252 | n,k = map(int,input().split())
lst = list(map(int,input().split()))
e,o = 0,0
for i in range(n):
if lst[i]%2==0:
e += 1
else:
o += 1
if o==0:
if p==0:
print(2**n)
else:
print(0)
else:
print(2**(n-1)) |
s357023879 | p03665 | u358254559 | 1579921954 | Python | Python (3.4.3) | py | Runtime Error | 344 | 24312 | 319 | N,P = map(int, input().split())
A = list(map(int, input().split()))
even_num=0
odd_num=0
for a in A:
if a%2==0:
even_num+=1
else:
odd_num+=1
ev_case = 2**even_num
from scipy.special import comb
res=0
for i in range(P,odd_num+1,2):
res += comb(odd_num, i, exact=True)
print(ev_case*res) |
s243356477 | p03665 | u474423089 | 1579921203 | Python | Python (3.4.3) | py | Runtime Error | 313 | 22668 | 365 | from scipy.special import comb
N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
odd = 0
even = 0
for i in A:
if i%2 !=0:
odd += 1
else:
even += 1
ans = 0
if P ==1:
for i in range(1,odd+1,2):
ans += comb(odd,i)
else:
for i in range(0,odd+1,2):
ans += co... |
s343168182 | p03665 | u987164499 | 1579753385 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 735 | from sys import stdin
from math import factorial
n,p = [int(x) for x in stdin.readline().rstrip().split()]
li = list(map(int,stdin.readline().rstrip().split()))
def combinations_count(n, r):
return factorial(n) // (factorial(n - r) * factorial(r))
guusu = 0
kisuu = 0
for i in li:
if i%2 == 0:
guusu ... |
s726782843 | p03665 | u767664985 | 1579663114 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 160 | N, P = map(int, input().split())
A = [i%2 for i in list(map(int, input().split))]
zero = A.count(0)
one = A.count(1)
print( (2**zero) * (2**(max(0, one-1))) )
|
s646012447 | p03665 | u644907318 | 1577460911 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 126 | N,P = map(int,input().split())
A = list(map(int,input().strip()))
cnt = 0
for i in range(N):
cnt += A[i]%2
print(2**(N-1)) |
s872007108 | p03665 | u828669332 | 1576471190 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 605 | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;
#define x first
#define y second
#define mp make_pair
#define pb push_back
typedef long long ll;
const ll MOD = 1e9+7;
int n, p;
ll memo[55][2];
int a[55];
ll dp(int pos, int o) {
if (pos == n) re... |
s329674292 | p03665 | u252828980 | 1576460917 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 619 | import math
a,b = map(int,input().split())
L = list(map(int,input().split()))
Le = [x for x in L if x%2 == 0]
Lo = [x for x in L if x%2 == 1]
#print(Le,Lo)
def nCr(n,r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
if b == 0:
ev = 0
od = 1
while ev <= len(Le)//2:
ev += ... |
s553824593 | p03665 | u814986259 | 1574090236 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 326 | from math import factorial
N,P=map(int,input().split())
a=list(map(int,input().split()))
odd=0
even=0
for i in range(N):
if a[i]%2==0:
even+=1
else:
odd+=1
ans=2**even
k=0
if P==0:
k=odd//2 +1
else:
k=(odd+1)//2
tmp=0
for i in range(1,k+1):
tmp+=factorial(odd)//factorial(odd-i)//factorial(i)
print(an... |
s823719779 | p03665 | u832152513 | 1573966707 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38428 | 569 | from scipy.special import comb
n, p = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
even = 0
for x in a:
if x % 2 == 1:
odd += 1
else:
even += 1
s_even = 0
for i in range(even):
s_even += comb(even, i+1, exact=True)
s_odd = 0
ans = 0
if p == 0:
for i in range(... |
s247685186 | p03665 | u353895424 | 1573341361 | Python | Python (3.4.3) | py | Runtime Error | 188 | 15412 | 796 | from scipy.special import comb
n, p = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
odd = []
even = []
#偶奇わけ
for _a in a:
if _a%2 == 0:
even.append(_a)
else:
odd.append(_a)
lenE = len(even)
lenO = len(odd)
totalE = 0
totalO = 0
for i in range(... |
s724583376 | p03665 | u779455925 | 1573272130 | Python | Python (3.4.3) | py | Runtime Error | 158 | 13320 | 379 | from scipy.special import comb
N,P=map(int,input().split())
A=list(map(int,input().split()))
A=[i%2 for i in A]
A0,A1=A.count(0),A.count(1)
if P==1:
if not A1:
print(0)
exit()
value0=0
for i in range(0,A0+1):
value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
value1+=comb(A... |
s545154126 | p03665 | u779455925 | 1573271996 | Python | Python (3.4.3) | py | Runtime Error | 217 | 15788 | 374 | from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
if not A1:
print(0)
exit()
value0=0
for i in range(0,A0+1):
value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
value1+=comb(A1, i,... |
s591213298 | p03665 | u779455925 | 1573271941 | Python | Python (3.4.3) | py | Runtime Error | 182 | 14164 | 450 | from scipy.special import comb
N,P=map(int,input().split())
A=list(map(lambda x:int(x)%2,input().split()))
A0,A1=A.count(0),A.count(1)
if P==1:
if not A1:
print(0)
exit()
value0=0
for i in range(0,A0+1):
#print(value0)
value0+=comb(A0, i, exact=True)
value1=0
for i in range(2-P,A1+1,2):
... |
s804844981 | p03665 | u183840468 | 1573169082 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 184 | a,b = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
l2 = [i for i in l if i %2 == 1]
if not l2 :
print(2**n if b == 0 else 0)
else:
print(2**(a-1)) |
s786681328 | p03665 | u109617108 | 1571619979 | Python | PyPy3 (2.4.0) | py | Runtime Error | 162 | 38384 | 242 | N,P=map(int,input().split())
L=list(map(int,input().split()))
for q in range(N):
L[q]=L[q]%2
s=0
if P==0:
s+=1
for i in range(N):
m=L[i]
for j in range(i+1,N):
for k in range(j,N+1):
m+=L[k]
i+=1
print(s)
|
s609740587 | p03665 | u941438707 | 1571603685 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 317 | from math import factorial as f
n,p,*a=map(int,open(0).read().split())
x=len([i for i in a if i%2])
y=n-x
xx=0
for i in range(p,x,2):
xx+=f(x)//f(i)//f(x-i)
yy=0
for i in range(0,y):
yy+=f(y)//f(i)//f(y-i)
if x>0 and y>0:
print(xx*yy+xx*(p^0)+yy*(p^1))
elif x==0:
print(yy(p^1))
else:
print(xx) |
s925335821 | p03665 | u131634965 | 1567621535 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 190 | n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( n%2 for i in a )
if total=0:
if p==0:
print(2**n)
else:
print(0)
else:
print(2**(n-1)) |
s539718561 | p03665 | u366959492 | 1567088369 | Python | PyPy3 (2.4.0) | py | Runtime Error | 163 | 38256 | 227 | n,p=map(int,input().split())
a=list(map(int,input().split()))
gu=0
ki=0
for i in a:
if a%2==0:
gu+=1
else:
ki+=1
if ki:
print(2**(n-1))
else:
if p:
print(0)
else:
print(2**n)
|
s541856123 | p03665 | u102461423 | 1560806584 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 186 | N,P = int(input())
A = [int(x) for x in input().split()]
odd = sum(x&1 for x in A)
if odd:
# どちらも半分ずつ
answer = 2**(N-1)
else:
answer = (2 ** N) * P
print(answer) |
s450527344 | p03665 | u388415336 | 1559634234 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 281 | num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd = len([a for a in bags if (a % 2 == 1]))
if congr_factor == 0 and odd == 0:
print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
print(0)
else:
print(2 ** (num_bags-1))
|
s434600085 | p03665 | u388415336 | 1559634175 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 292 | num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1]))
if congr_factor == 0 and odd == 0:
print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
print(0)
else:
print(2 ** (num_bags-1))
|
s541815454 | p03665 | u693953100 | 1558628903 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 232 | def check(a):
for i in a:
if i%2:
return True
return False
n,p = map(int, input().split())
a = list(map(int,input().split()))
if check():
print(2**(n-1))
elif p==0:
print(2**n)
else:
print(0) |
s938698873 | p03665 | u859897687 | 1554983886 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 214 | n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a,b=0,0
for i in l:
if l%2>0:
a+=1
else:
b+=1
if a==0:
if p==0:
print(2**n)
else:
print(0)
else:
print(2**(n-1)) |
s182614064 | p03665 | u187205913 | 1553281105 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 192 | n,p=map(int,input().split())
a = list(map(int,input().split()))
for a_ in a:
if not a_%2==0:
k=1
break
if k:
print(1<<(n-1))
else:
print(0) if p==1 else print(1<<n) |
s504360532 | p03665 | u941753895 | 1551917142 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 467 | import math
def ncr(n,r):
return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
n,p=map(int,input().split())
l=list(map(int,input().split()))
l1=[]
l2=[]
for i in l:
if i%2==0:
l1.append(i)
else:
l2.append(i)
c=0
su=0
le1=len(l1)
le2=len(l2)
while True:
if le1+le2<c:
break
if c%2==0:
... |
s875448450 | p03665 | u335295553 | 1550174201 | Python | Python (3.4.3) | py | Runtime Error | 195 | 14752 | 808 | from scipy.special import comb
N, P = map(int,input().split())
A = list(map(int,input().split()))
odd = 0
even= 0
res = 0
for i in A:
if i%2:
odd += 1
else:
even += 1
'''
if P==0:
res += 1
if odd >= 2:
odd -= 2
res += uoo(odd)
if even >= 1:
res += 2**even
... |
s221237202 | p03665 | u404676457 | 1548300465 | Python | Python (3.4.3) | py | Runtime Error | 164 | 15348 | 337 | import collections, scipy.special
n, p = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] %= 2
c = collections.Counter(a)
zero = c[0]
one = c[1]
ans = 0
if p == 0:
s = 0
else:
s = 1
for i in range(s, one + 1, 2):
ans += 2 ** zero * scipy.special.comb(one, i, exact=... |
s351139966 | p03665 | u404676457 | 1548300199 | Python | Python (3.4.3) | py | Runtime Error | 347 | 23648 | 333 | import collections, scipy.special
n, p = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
a[i] %= 2
c = collections.Counter(a)
zero = c[0]
one = c[1]
ans = 0
if p == 0:
s = 0
else:
s = 1
for i in range(s, one, 2):
ans += 2 ** zero * scipy.special.comb(one, i, exact=True... |
s945777781 | p03665 | u391331433 | 1546097430 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2568 | 856 | import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
if fileobject == None :
return raw_input
else:
return fileobject.readline
def main():
if len(sys.argv) > 1:
f = open(sys.argv[1])
else:
f = None
read_func = get_read_func... |
s787398900 | p03665 | u427344224 | 1540400819 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 191 | N, P = map(int, input().split())
a_list = list(map(int, input().split()))
a=[i%2 for i in a_list]
if sum(a)>0:print(2**(N-1))
else:
if M==0:
print(2**N)
else:
print(0) |
s539365411 | p03665 | u017810624 | 1539135219 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 186 | n,p=map(int,input().split())
a=list(map(int,input().split()))
c=0
for i in range(n):
if a[i]%2==1:
c=1
break
if c=1:print(2**(n-1))
else:
if p=0:print(2**(n))
else:print(0) |
s316576757 | p03665 | u589087860 | 1539047099 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 183 | n, p = map(int, input().split())
a = list(input())
for i in len(a):
if i % 2 == 1:
print(2 ** (n - 1))
exit(0)
if p == 0:
print(2 ** n)
else:
print(0)
|
s728004385 | p03665 | u589087860 | 1539047059 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 178 | n, p = map(int, input().split())
a = list(input())
for i in a:
if i % 2 == 1:
print(2 ** (n - 1))
exit(0)
if p == 0:
print(2 ** n)
else:
print(0)
|
s978136182 | p03665 | u876335718 | 1537993989 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 262 | asdf1 (Guest)
コンテスト時間: 2017-07-09(日) 21:00 ~ 2017-07-09(日) 23:00 AtCoderホームへ戻る
トップ
問題
質問
提出
提出一覧
順位表
コードテスト
解説
コードテスト
言語
C++14 (GCC 5.4.1)
ソースコード
|
s389273547 | p03665 | u863370423 | 1532919206 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 317 | from sys import stdin
n, p = map(int, stdin.readline().split(' '))
a = map(int, stdin.readline().split(' '))
dp = [ [[None] * (n + 1)], [[None] * (n + 1)] ]
dp[p][n] = 1
dp[1-p][n] = 0
for i in xrange(n-1, -1, -1):
for k in [0,1]: dp[k][i] = dp[k][i+1] + dp[(k+a[i])%2][i+1]
#print dp
res = dp[0][0]
print res |
s976289640 | p03665 | u329865314 | 1525125193 | Python | Python (3.4.3) | py | Runtime Error | 75 | 3988 | 438 | tmp = list(map(int,input().split()))
As = list(map(int,input().split()))
n,p = tmp[0],tmp[1]
o ,e = 0,0
for i in range(n):
if As[i] % 2:
o += 1
else:
e += 1
def comb(j,k):
if k == 1:
return(j)
else:
return comb(j-1,k-1) * j / k
ans = 0
if p == 0:
for i in range(o+1):
if not i % 2:
a... |
s922150993 | p03665 | u875361824 | 1522724533 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 808 | def main():
N, P = map(int, input().split())
*A, = map(int, input().split())
editorial(N, P, A)
def editorial(N, P, A):
odds = [a for a in A if a % 2 == 1]
odd = len(odds)
even = N - odd
if odd == 0:
if P = 1:
print(0)
else:
print(2 ** N)
re... |
s059539776 | p03665 | u559823804 | 1519788221 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 77 | n,p=map(int,input().split())
a=list(map(int,input().split()))
print(2**(N-1)) |
s894214756 | p03665 | u667084803 | 1501656013 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 183 | ,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
for i in range(N):
if A[i]%2==1: odd+=1
if odd==0:
if P==1: print(0)
else: print(2**N)
else:
print(2**(N-1)) |
s024091909 | p03665 | u667084803 | 1501655993 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 194 | N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
for i in range(N):
if A[i]%2==1: odd+=1
break
if odd==0:
if P==1: print(0)
else: print(2**N)
else:
print(2**(N-1)) |
s490592846 | p03665 | u835482198 | 1500836083 | Python | Python (2.7.6) | py | Runtime Error | 10 | 2568 | 233 |
N, P = map(int, input().split())
A = map(int, input().split())
n_even = len(filter(lambda x: x % 2 == 0, A))
n_odd = N - n_even
ans = 2 ** max(0, n_odd - 1) * 2 ** n_even
if P == 0 and n_odd == 0:
print(0)
else:
print(ans)
|
s537821740 | p03665 | u835482198 | 1500835965 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 233 |
N, P = map(int, input().split())
A = map(int, input().split())
n_even = len(filter(lambda x: x % 2 == 0, A))
n_odd = N - n_even
ans = 2 ** max(0, n_odd - 1) * 2 ** n_even
if P == 0 and n_odd == 0:
print(0)
else:
print(ans)
|
s500846902 | p03665 | u667084803 | 1499921180 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 456 | import math
def comb(n,r):
return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))
N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
even=0
total=0
for i in range(N):
total+=A[i]
if A[i]%2==0:
even+=1
else:
odd+=1
total=total%2
evens=2**even
ans=0
if total==even%2:
f... |
s664255661 | p03665 | u667084803 | 1499921136 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 458 | import math
def comb(n,r):
return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))
N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=0
even=0
total=0
for i in range(N):
total+=A[i]
if A[i]%2==0:
even+=1
else:
odd+=1
total=total%2
evens=2**even
ans=0
if total==even%2:
f... |
s634063879 | p03665 | u608297208 | 1499827873 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 417 | N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
flag = 10 **9
else:
flag = pow(D,N -1)
B -= A
if N % 2 == 1:
if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
print("YES")
else:
print("NO")
else:
if abs(B % (C + D) - (D + C)... |
s335881078 | p03665 | u821262411 | 1499714742 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 513 | for i in a:
if i%2==0:
k +=1
m=n-k
ans_x=ans_y=0
def cbn(b,c):
z=1
for i in range(2,b+1):
z *= i
for i in range(2,c+1):
z //= i
for i in range(2,b-c+1):
z //= i
return(z)
if p==0:
for i in range(k+1):
ans_x += cbn(k,i)
for i in range(0,m+1,2):... |
s505423385 | p03665 | u846552659 | 1499655298 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 606 | N, P = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
odd = [ tmp for tmp in a if tmp%2 != 0]
even = [ tmp for tmp in a if tmp%2 == 0]
if P == 0:
ans += 1
b = sum([ len(list(itertools.combinations(odd,tmp))) for tmp in range(2, len(odd)+1, 2) ])
else:
b = sum([ len(list(itertools.comb... |
s913594505 | p03665 | u794543767 | 1499655153 | Python | Python (3.4.3) | py | Runtime Error | 292 | 21512 | 203 | import numpy as np
hoge = input()
N,A,B,C,D = list(map(int,hoge.split(" ")))
k = np.abs(B-A)//D
l = np.abs(B-A)%D
times = k + 2 * np.ceil (l/ (D-C))
if times > N-2:
print("NO")
else:
print("YES") |
s511883030 | p03665 | u794543767 | 1499655061 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 184 | hoge = input()
N,A,B,C,D = list(map(int,hoge.split(" ")))
k = np.abs(B-A)//D
l = np.abs(B-A)%D
times = k + 2 * np.ceil (l/ (D-C))
if times > N-2:
print("NO")
else:
print("YES") |
s973909945 | p03665 | u981890679 | 1499654359 | Python | Python (2.7.6) | py | Runtime Error | 2104 | 2696 | 933 | # -*- coding: utf-8 -*-
import sys
N,P = map(int, raw_input().split())
a = map(int, raw_input().split())
count_0 = 0
count_1 = 0
number = 0
def comb(n,r):
if n < 0 or r < 0 or n < r:
return 0
elif n == 0 or r == 0:
return 1
else:
return comb(n-1,r-1)+comb(n-1,r)
for i in range(N... |
s157778596 | p03665 | u432688695 | 1499651914 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 925 | # -*- coding: utf-8 -*-
import sys
import os
input_text_path = __file__.replace('.py', '.txt')
fd = os.open(input_text_path, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())
N, P = map(int, input().split())
A_temp = list(map(int, input().split()))
A = []
for a in A_temp:
A.append(a % 2)
zero_num = A.count(0)
one_... |
s657277450 | p03665 | u846372029 | 1499651802 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 217 | #Biscuits
N,P = list(map(int, input().split()))
A = list(map(int, input().split()))
#奇数の数
k = 0
for a in A:
if a%2 ==1:
k+=1
if ( k ==0 ):
ans = int(p==0)
else:
ans = 2**(N-1)
print(ans) |
s194714251 | p03665 | u846372029 | 1499651665 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 206 | #Biscuits
N,P = list(map(int, input().split()))
A = list(map(int, input().split()))
#奇数の数
k = sum([A[i]%2 for i in range(N)])
if ( k ==0 ):
ans = int(p==0)
else:
ans = 2**(N-1)
print(ans) |
s496808791 | p03665 | u704252625 | 1499651598 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 523 | def nCk(n, k):
ans = 1
i = 0
while i < k:
ans *= n - i
i += 1
i = 1
while i <= k:
ans /= i
i += 1
return ans
def main():
[N, P] = map(int, raw_input().split())
even = 0
odd = 0
A = map(int, raw_input().split())
i = 0
while i < N:
i... |
s229038522 | p03665 | u704252625 | 1499651517 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 554 | def nCk(n, k):
ans = 1
i = 0
while i < k:
ans *= n - i
i += 1
i = 1
while i <= k:
ans /= i
i += 1
return ans
def main():
[N, P] = map(int, raw_input().split())
even = 0
odd = 0
A = map(int, raw_input().split())
i = 0
while i < N:
i... |
s777049976 | p03665 | u238510421 | 1499650925 | Python | Python (3.4.3) | py | Runtime Error | 391 | 25012 | 782 | import numpy as np
import itertools
from scipy.special import comb
n,p =input().split()
n = int(n)
p = int(p)
a_list = input().split()
a_list = [int(x) for x in a_list]
a_array = np.array(a_list)
amari = a_array % 2
zero_count = np.sum(amari == 0)
one_count = np.sum(amari == 1)
zero_pattern = 2**zero_count
if p =... |
s338914679 | p03665 | u238510421 | 1499650813 | Python | Python (3.4.3) | py | Runtime Error | 1121 | 23852 | 964 | import numpy as np
import itertools
from scipy.special import comb
n,p =input().split()
n = int(n)
p = int(p)
a_list = input().split()
a_list = [int(x) for x in a_list]
a_array = np.array(a_list)
amari = a_array % 2
zero_count = np.sum(amari == 0)
one_count = np.sum(amari == 1)
zero_pattern = 2**zero_count
if p =... |
s711171995 | p03665 | u292868516 | 1499649201 | Python | Python (2.7.6) | py | Runtime Error | 11 | 2696 | 463 | #!/usr/bin/env python
# encoding: utf-8
n, p = map(int, raw_input().split())
o, e = 0, 0
a = map(int, raw_input().split())
for i in xrange(n):
x = a[i]
if x % 2 == 0:
e += 1
else:
o += 1
C = [[]]
for i in xrange(1, 51):
C.append(range(51))
C[i][0] = C[i][i] = 1
for j in xrange... |
s739773463 | p03665 | u237316771 | 1499649076 | Python | Python (2.7.6) | py | Runtime Error | 24 | 3500 | 559 | def ncr(n, r):
ans = 1
if r * 2 >= n:
return ncr(n, n - r)
for i in xrange(n - r + 1, n + 1):
ans *= i
for i in xrange(1, r + 1):
ans //= i
return ans
def main():
n, p = [int(_) for _ in raw_input().split()]
o = 0
e = 0
for ai in (int(_) for _ in raw_input()... |
s846250195 | p03666 | u367701763 | 1597960227 | Python | PyPy3 (7.3.0) | py | Runtime Error | 113 | 117488 | 244 | from bisect import *
N, A, B, C, D = map(int, input().split())
P = [A + (N-1-i)*D - C*i for i in reversed(range(N))]
Q = [A + (N-1-i)*C - D*i for i in reversed(range(N))]
j = bisect_left(P,B)
if B >= Q[j]:
print("YES")
else:
print("NO") |
s440424079 | p03666 | u754022296 | 1580261012 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 161 | N, A, B, C, D = map(int, input().split())
E = B - A
for m in range(N):
if C*(N-1-m) - D*m <= E <= -C*m + (N-1-m)*D:
print("YES")
break
else
print("NO") |
s053110013 | p03666 | u141610915 | 1577167839 | Python | PyPy3 (2.4.0) | py | Runtime Error | 181 | 42224 | 591 | import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
dp = [0] * N
dp[0] = A
dp[-1] = B
x = -1
def no():
print("NO")
exit(0)
if B < A: A, B = B, A
for i in range(N - 2):
if dp[i] < B:
dp[i + 1] = dp[i] + D
else:
#print(dp[i], (i - 1) * (D - C), B)
f = abs(dp[i] - (i - 1) *... |
s117534669 | p03666 | u141610915 | 1577167566 | Python | PyPy3 (2.4.0) | py | Runtime Error | 188 | 43248 | 586 | import sys
input = sys.stdin.readline
N, A, B, C, D = map(int, input().split())
dp = [0] * N
dp[0] = A
dp[-1] = B
x = -1
def no():
print("NO")
exit(0)
if B < A: A, B = B, A
for i in range(N - 2):
if dp[i] < B:
dp[i + 1] = dp[i] + D
else:
#print(dp[i], (i - 1) * (D - C), B)
if abs(dp[i] - (i - 1) * ... |
s398334025 | p03666 | u871980676 | 1576390851 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 452 | n,a,b,c,d=map(int,input().split())
e=abs(b-a)
if c+d+e==0:
print("YES")
exit()
upper=(e+(n-1)*d)//(c+d)
lower=(e+(n-1)*c)//(c+d)
if upper==lower:
if (e+(n-1)*c) % (c+d) == 0 and 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
print("YES")
print(2//0)
else:
print(... |
s234243480 | p03666 | u871980676 | 1576390605 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 349 | n,a,b,c,d=map(int,input().split())
e=abs(b-a)
if c+d+e==0:
print("YES")
exit()
upper=(e+(n-1)*d)//(c+d)
lower=(e+(n-1)*c)//(c+d)
if upper==lower:
if (e+(n-1)*c) % (c+d) == 0 and 0<=lower and (e+(n-1)*c)/(c+d) <= n-1 and e <= (n-1)*max([c,d]):
print("YES")
print(2//0)
else:
print(... |
s928590400 | p03666 | u814986259 | 1576298050 | Python | Python (3.4.3) | py | Runtime Error | 157 | 3188 | 391 | N,A,B,C,D=map(int,input().split())
if A> B:
A,B=B,A
if C>D:
C,B=B,C
if B-A>D*(N-1):
print("NO")
elif B-A>=C*(N-1):
print("YES")
else:
flag=False
diff=B-A
d=0
for i in range(2,N,2):
d+=D-C
j= N-1 - i
if j==0:
if diff==d:
flag=True
break
k=(diff - d) / j
if k>=C and... |
s436258122 | p03666 | u828766688 | 1570668994 | Python | PyPy3 (2.4.0) | py | Runtime Error | 177 | 38256 | 724 |
N,M,D = map(int,input().split())
A = list(map(int,input().split()))
lis = [i for i in range(N)]
for i in range(M):
a = A[i] - 1
k = lis[a]
lis[a] = lis[a+1]
lis[a+1] = k
#print (lis)
end = [False] * N
endp = 0
ans = [None] * N
while endp < N:
if end[endp]:
endp += 1
else:
... |
s700391074 | p03666 | u729133443 | 1569461104 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 108 | n,a,b,c,d=map(int,input().split());print('NYOE S'[any(i*c-(~i+n)*d<=b-a<=i*d-(~i+n)*cfor i in range(n))::2]) |
s303132681 | p03666 | u572144347 | 1551928342 | Python | PyPy3 (2.4.0) | py | Runtime Error | 169 | 38256 | 971 | N,A,B,C,D=map(int,input().split())
#print("target:", abs(A-B))
#print("range: ", D-C)
#print("target is larger than D: " ,
# abs(A-B)>D)
#target=abs(A-B)
#print("next target is: ", target-D)
#print("how many? : ", (target-D)//(D-C))
ans=False
def g(a,b,c,d,n):
if (n-1)%2==0:
target=abs(a-b) #スタートは0
gai... |
s184709793 | p03666 | u161911516 | 1508081328 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 387 |
input1s = input()
input1 = [int(i) for i in input1s.split(' ')]
N = input1[0]
A = input1[1]
B = input1[2]
C = input1[3]
D = input1[4]
AB = math.fabs(A-B)
DC = math.fabs(D-C)
m = N-2
if((N-2)%2 == 0):
if( C-m*(D-C) <= AB and AB <= m*(D-C)+D ):
print("YES")
else:
print("NO")
if((N-2)%2 == 1):
if( 0 <= A... |
s459506392 | p03666 | u608297208 | 1499826620 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 473 | N,A,B,C,D = map(int,input().split())
if N > 30 and D > 1:
flag = 10 **9
else:
flag = pow(D,N -1)
B -= A
if N % 2 == 1:
if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
print("YES")
else:
print("NO")
else:
if ((B - (D + C) / 2) % (C +... |
s278162718 | p03666 | u101225820 | 1499655500 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 198 | N,A,B,C,D=map(int,input().split())
N=N-2
for i in range(0,N+1):
l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))
for _ in l:
if B-A in _:
print("YES")
break
else:
print("NO")
|
s042968674 | p03666 | u101225820 | 1499655416 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 191 | N,A,B,C,D=map(int,input().split())
for i in range(0,N-1):
l.append(range(i*C-(N-i)*D,i*D-(N-i)*C+1))
for _ in l:
if B-A in _:
print("YES")
break
else:
print("NO") |
s823767461 | p03666 | u608297208 | 1499655334 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 483 | N,A,B,C,D = map(int,input().split())
if N > 18 and D > 1:
flag = 10 **9
else:
flag = pow(D,N)
B -= A
if N % 2 == 1:
if (B % (C + D) <= (N - 1) * (D - C) / 2 or abs(B % (C + D) - (C + D)) <= (N - 1) * (D - C) / 2) and B <= flag and B >= -flag:
print("YES")
else:
print("NO")
else:
if (abs(B % (C + D) - (D - C) /... |
s842157734 | p03666 | u264683849 | 1499655285 | Python | Python (3.4.3) | py | Runtime Error | 42 | 5076 | 1196 | from fractions import gcd
N,A,B,C,D=map(int,input().split())
if B<A:
A,B=B,A
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, x, y = egcd(b % a, a)
return (g, y - (b // a) * x, x)
if C==0 and D==0:
if A==B:
print("YES")
else:
print("NO")
elif C==0 or D==0:
... |
s647143907 | p03666 | u794543767 | 1499655111 | Python | Python (3.4.3) | py | Runtime Error | 294 | 21360 | 145 | import numpy as np
k = np.abs(B-A)//D
l = np.abs(B-A)%D
times = k + 2 * np.ceil (l/ (D-C))
if times > N-2:
print("NO")
else:
print("YES") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.