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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s105577904 | p03848 | u923712635 | 1561564771 | Python | PyPy3 (2.4.0) | py | Runtime Error | 217 | 55532 | 422 | N = int(input())
A = [int(x) for x in input().split()]
mod = 10**9+7
c = 1-N%2
flag = True
di = {}
for i in A:
if(i not in di):
di[i]=1
else:
di[i]+=1
for i in range(N//2):
if(i+c==0):
flag &= (di[i]==1)
else:
flag &= (di[i*2+c]==2)
if(not flag):
if(N==1):
print(1)
else:
print(0)
break
else:
print((2<<(N//2-1))%mod)
|
s924951352 | p03848 | u854831509 | 1560833826 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 1044 | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;
int dy[]={1,-1,0,0};
int dx[]={0,0,1,-1};
int main(){
int N;
cin>>N;
vector<int> a(N);
for(int i=0;i<N;i++){
cin>>a[i];
}
//整合性チェック
int guki=N%2;
vector<int> num((N+1)/2,0);
bool flag=true;
for(int i=0;i<N;i++){
if(guki==1){
if(a[i]%2==1||a[i]>2*(N/2)){
flag=false;
break;
}
num[a[i]/2]++;
}else{
if(a[i]%2==0||a[i]>2*((N-1)/2)+1){
flag=false;
break;
}
num[a[i]/2]++;
}
}
for(int i=0;i<num.size();i++){
if(guki==1&&i==0){
if(num[i]!=1){
flag=false;
break;
}
}else if(num[i]!=2){
flag=false;
break;
}
}
if(!flag){
cout<<"0"<<endl;
return 0;
}
ll ans=1;
if(guki==1){
for(int i=0;i<num.size()-1;i++){
(ans*=2)%=mod;
}
}else{
for(int i=0;i<num.size();i++){
(ans*=2)%=mod;
}
}
cout<<ans<<endl;
return 0;
}
|
s261151139 | p03848 | u551909378 | 1559334015 | Python | Python (3.4.3) | py | Runtime Error | 90 | 13880 | 453 | N = int(input())
A = sorted([int(x) for x in input().split()])
def check():
if N % 2 == 0:
for i in range(1,N)[::2]:
if A[i-1] != i or A[i] != i: return 0
return int(2**(N/2)) % (1e9+7)
else:
if A[0] != 0: return 0
else:
for i in range(2,N)[::2]:
if A[i-1] != i or A[i] != i: return 0
return int(2**((N-1)/2)) % int(1e9+7)
print(int(check()))
|
s260171310 | p03848 | u551909378 | 1559333439 | Python | Python (3.4.3) | py | Runtime Error | 90 | 13880 | 436 | N = int(input())
A = sorted([int(x) for x in input().split()])
def check():
if N % 2 == 0:
for i in range(1,N)[::2]:
if A[i-1] != i or A[i] != i: return 0
return (2**(N/2)) % (1e9+7)
else:
if A[0] != 0: return 0
else:
for i in range(2,N)[::2]:
if A[i-1] != i or A[i] != i: return 0
return (2**((N-1)/2)) % (1e9+7)
print(int(check()))
|
s180812811 | p03848 | u785578220 | 1559274102 | Python | Python (3.4.3) | py | Runtime Error | 92 | 14008 | 514 |
a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
if x[0] == 0:print(1)
else:print(0)
else:
if a %2 == 0:
for i in range(1,a,2):
if not i == x[-1] and i ==x[-2]:
print(0)
break
x.pop()
x.pop()
else:print(2**(a//2))
else:
if x.pop() != 0:
print(0)
exit()
for i in range(0,a,2):
if not i == x[-1] and i ==x[-2]:
print(0)
break
x.pop()
x.pop()
else:print(2**(a//2))
|
s744688170 | p03848 | u785578220 | 1559273932 | Python | Python (3.4.3) | py | Runtime Error | 77 | 14008 | 536 | a = int(input())
x = list(map(int, input().split()))
x.sort()
t =[2]
x = x[::-1]
if a == 1:
if x[0] == 0:print(1)
else:print(0)
else:
if a %2 == 0:
print(t[3])
for i in range(1,a,2):
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2))
else:
if x.pop() != 0:
print(0)
exit()
for i in range(0,a,2):
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2)) |
s330111480 | p03848 | u785578220 | 1559273553 | Python | Python (3.4.3) | py | Runtime Error | 88 | 14008 | 388 | a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a %2 == 0:
for i in range(1,a,2):
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2))
else:
for i in range(0,a,2):
x.pop()
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2))
|
s143982956 | p03848 | u785578220 | 1559273548 | Python | PyPy3 (2.4.0) | py | Runtime Error | 216 | 52204 | 388 | a = int(input())
x = list(map(int, input().split()))
x.sort()
x = x[::-1]
if a %2 == 0:
for i in range(1,a,2):
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2))
else:
for i in range(0,a,2):
x.pop()
if not i == x[-1] and i ==x[-2]:
x.pop()
x.pop()
print(0)
break
else:print(2**(a//2))
|
s122901489 | p03848 | u497596438 | 1558039406 | Python | PyPy3 (2.4.0) | py | Runtime Error | 222 | 52332 | 418 | N=int(input())
A=list(map(int,input().split()))
A.sort()
INF=1e9+7
if N%2==1:
if A[0]!=0:
print(0)
quit()
for i in range((N-1)//2):
if A[2*i+1]!=2*(i+1) or A[2*i+2]!=2*(i+1):
print(0)
quit()
print(2**((N-1)//2)%INF)
else:
for i in range(N//2):
if A[2*i]!=2*i+1 or A[2*i+1]!=2*i+1:
print(0)
quit()
print(2**(N//2)%INF)
|
s834071642 | p03848 | u802772880 | 1557442935 | Python | Python (3.4.3) | py | Runtime Error | 96 | 14008 | 417 | n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
if a[0]!=0:
print(0)
exit()
for i in range(n//2):
if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
print(0)
exit()
print((pow(2,n//2))%(1e9+7))
else:
for i in range(n//2):
if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
print(0)
exit()
print((pow(2,n//2))%(1e9+7)) |
s030141432 | p03848 | u802772880 | 1557442864 | Python | Python (3.4.3) | py | Runtime Error | 97 | 14004 | 419 | n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
if a[0]!=0:
print(0)
exit()
for i in range(n//2):
if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
print(0)
exit()
print((pow(2,n//2))%(1e9+7))
else:
for i in range(n//2):
if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
print(0)
exit()
print(((pow(2,n//2))%(1e9+7))) |
s127028508 | p03848 | u802772880 | 1557442384 | Python | Python (3.4.3) | py | Runtime Error | 97 | 14008 | 423 | n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
if a[0]!=0:
print(0)
exit()
for i in range(n//2):
if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
print(0)
exit()
print(int(pow(2,n//2)%(1e9+7)))
else:
for i in range(n//2):
if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
print(0)
exit()
print(int(pow(2,n//2)%(1e9+7))) |
s676420063 | p03848 | u802772880 | 1557440903 | Python | Python (3.4.3) | py | Runtime Error | 99 | 14008 | 413 | n=int(input())
a=list(map(int,input().split()))
a.sort()
if n%2==1:
if a[0]!=0:
print(0)
exit()
for i in range(n//2):
if a[2*i+1]!=2*(i+1) or a[2*(i+1)]!=2*(i+1):
print(0)
exit()
print(pow(2,n//2)%(1e9+7))
else:
for i in range(n//2):
if a[2*i]!=2*i+1 or a[2*i+1]!=2*i+1:
print(0)
exit()
print(pow(2,n//2)%(1e9+7)) |
s831863706 | p03848 | u802772880 | 1557438812 | Python | Python (3.4.3) | py | Runtime Error | 2104 | 14008 | 497 | n=int(input())
a=list(map(int,input().split()))
ans=1
a.sort()
la=list(set(a))
if n%2==0:
for i in range(1,n,2):
if a.count(i)==2:
ans*=2
ans%=1e9+7
else:
ans=0
break
else:
if a[0]==0 and a[1]!=0:
a=a[1:]
for i in range(2,n,2):
if a.count(i)==2:
ans*=2
ans%=1e9+7
else:
ans=0
break
else:
ans=0
print(int(ans)) |
s079956378 | p03848 | u442581202 | 1557169165 | Python | Python (3.4.3) | py | Runtime Error | 74 | 14436 | 425 | n = int(input())
dat = list(map(int,input().split()))
cnt = dict()
for d in dat:
if cnt.__contains__(d):
cnt[d]+=1
else:
cnt[d]=1
if n%2:
if cnt[0] != 1:
print(0)
exit(0)
for i in range(2,n,2):
if cnt[i] != 2:
print(0)
exit(0)
else:
for i in range(1,n,2):
if cnt[i] != 2:
print(0)
exit(0)
print(2**(n//2))
|
s810358044 | p03848 | u063052907 | 1556245676 | Python | Python (3.4.3) | py | Runtime Error | 67 | 14820 | 371 | from collections import Counter
N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
if N % 2:
if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
ans = pow(2, N//2, mod)
else:
ans = 0
else:
if all(countA[i] == 2 for i in range(1, N, 2)):
ans = pow(2, N//2, mod)
print(ans) |
s689058942 | p03848 | u063052907 | 1556245234 | Python | Python (3.4.3) | py | Runtime Error | 65 | 14820 | 375 | from collections import Counter
N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
if N % 2:
if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
ans = 2 ** (N // 2) % mod
else:
ans = 0
else:
if all(countA[i] == 2 for i in range(1, N, 2)):
ans = 2 ** (N // 2) % mod
print(ans) |
s763255839 | p03848 | u063052907 | 1556244939 | Python | Python (3.4.3) | py | Runtime Error | 66 | 14820 | 373 | from collections import Counter
N = int(input())
lstA = list(map(int, input().split()))
mod = 10**9 + 7
countA = Counter(lstA)
if N % 2:
if countA[0] == 1 and all(countA[i] == 2 for i in range(2, N, 2)):
ans = pow(2, N//2) % mod
else:
ans = 0
else:
if all(countA[i] == 2 for i in range(1, N, 2)):
ans = pow(2, N//2) % mod
print(ans) |
s872487942 | p03848 | u859897687 | 1556109031 | Python | Python (3.4.3) | py | Runtime Error | 52 | 10616 | 253 | n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
m[i]+=1
ans=1
for i in range(n-1,0,-2):
if d[i]!=2:
ans=0
if d[0]!=n%2:
ans=0
if ans:
print(2**(n//2)%1000000007)
else:
print(0)
|
s039549768 | p03848 | u859897687 | 1556108951 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 250 | n=int(input())
#ne,[7,5,3,1,1,3,5,7]8
#no,[8,6,4,2,0,2,4,6,8]9
m=[0]*n
for i in map(int,input().split()):
m[i]+=1
ans=1
for i in range(n-1,0,-2):
d[i]!=2:
ans=0
if d[0]!=n%2:
ans=0
if ans:
print(2**(n//2)%1000000007)
else:
print(0)
|
s301336839 | p03848 | u102960641 | 1555969875 | Python | Python (3.4.3) | py | Runtime Error | 103 | 13880 | 293 | n = int(input())
a = list(map(int, input().split()))
a.sort()
b = True
for i,j in enumerate(a):
if n % 2:
if j != ((i+1) // 2) * 2:
b = False
break
else:
if j != (i // 2) * 2 + 1:
b = False
break
if b == True:
print(((n // 2) ** 2) % mod)
else:
print(0) |
s652752198 | p03848 | u102960641 | 1555969726 | Python | Python (3.4.3) | py | Runtime Error | 103 | 13880 | 303 | n = int(input())
a = list(map(int, input().split()))
a.sort()
mod = 10 ** 9 + 7
b = True
for i,j in enumerate(a):
if n % 2:
if j != ((i+1) // 2) * 2:
b = False
break
else:
if j != (i // 2) * 2 + 1:
b = False
break
print((n // 2) ** 2) % mod if b == True else print(0) |
s616317816 | p03848 | u804358525 | 1555956906 | Python | Python (3.4.3) | py | Runtime Error | 100 | 13880 | 610 | # -*- coding: utf-8 -*-
people_num = int(input())
line_list = list(map(int, input().split()))
num_odd = True
bool_false = True
line_list.sort()
if(people_num%2 == 0):
num_odd = False
for i in range(people_num):
if(num_odd):
if(line_list[i] == 2*((i+1)//2)):
continue
else:
bool_false = False
break
else:
if(line_list[i] == 2*((i)//2) +1):
continue
else:
bool_false = False
break
if(len(people_num) == 1):
print(1)
elif(bool_false):
print((people_num//2) **2)
else:
print(0) |
s447930208 | p03848 | u434208140 | 1552247915 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 551 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)
ll pw(ll n,ll m){
if(m==0) return 1;
else if(m%2==0) return pw(n*n,m/2);
else return n*pw(n,m-1);
}
int main(){
ll n,a[100010];
cin>>n;
fr(i,n) cin>>a[i];
sort(a,a+n);
for(int i=n-1;i>=0;i-=2) a[i]++;
bool f=1;
fr(i,n) if(a[i]!=i+1) f=0;
cout<<(f?pw(2,n/2):0)<<endl;
} |
s779929400 | p03848 | u485137520 | 1549062240 | Python | Python (3.4.3) | py | Runtime Error | 88 | 13880 | 333 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
if 0 in co:
co.remove(0)
co.sort()
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list))[:-1:2]:
if not co[index] == co[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s401600112 | p03848 | u485137520 | 1549062126 | Python | Python (3.4.3) | py | Runtime Error | 86 | 13812 | 333 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
if 0 in co:
co.remove(0)
co.sort()
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list))[:-2:2]:
if not co[index] == co[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s189130759 | p03848 | u485137520 | 1549062000 | Python | Python (3.4.3) | py | Runtime Error | 88 | 13880 | 336 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
if 0 in co:
co.remove(0)
co.sort()
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list))[:-1:2]:
if not co[index] == co[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s191471418 | p03848 | u485137520 | 1549061943 | Python | Python (3.4.3) | py | Runtime Error | 164 | 14008 | 380 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
if 0 in co:
co.remove(0)
co.sort()
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list))[:-1:2]:
print(co[index])
print(co[index+1])
if not co[index] == co[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s464258818 | p03848 | u485137520 | 1549061916 | Python | Python (3.4.3) | py | Runtime Error | 167 | 14008 | 376 | n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
if 0 in co:
co.remove(0)
co.sort()
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list))[::2]:
print(co[index])
print(co[index+1])
if not co[index] == co[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s092607017 | p03848 | u485137520 | 1549061689 | Python | Python (3.4.3) | py | Runtime Error | 80 | 13880 | 344 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
co.sort()
if 0 in co:
co.remove(0)
if not len(co) % 2 == 0:
print(0)
quit()
for index in range(len(a_list)[:-1:2]):
if not a_list[index] == a_list[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s145393213 | p03848 | u485137520 | 1549061439 | Python | Python (3.4.3) | py | Runtime Error | 81 | 14008 | 342 | n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
co.sort()
if 0 in co or len(co) % 2 == 1:
co.remove(0)
else:
print(0)
quit()
for index in range(len(a_list)[:-1:2]):
if not a_list[index] == a_list[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s510353646 | p03848 | u485137520 | 1549061395 | Python | Python (3.4.3) | py | Runtime Error | 83 | 14008 | 342 |
n = int(input())
a_list = list(map(int, input().split()))
co = a_list.copy()
co.sort()
if 0 in co or len(co) % 2 == 1:
co.remove(0)
else:
print(0)
quit()
for index in range(len(a_list)[::2]):
if not a_list[index] == a_list[index + 1]:
print(0)
quit()
print(int(pow(2, floor(n / 2))) % (pow(10,9) + 7)) |
s806803455 | p03848 | u397531548 | 1544909578 | Python | Python (3.4.3) | py | Runtime Error | 70 | 16352 | 521 | import collections
N=int(input())
A=list(map(int,input().split()))
if N%2==1:
if 0 not in A:
print(0)
else:
B=A.remove(0)
Bc=dict(collections.Counter(B))
for i in Bc.keys():
if Bc[i]!=2:
print(0)
break
else:
print(2**(B//2)%(10**9+7))
else:
Bc=dict(collections.Counter(A))
for i in Bc.keys():
if Bc[i]!=2:
print(0)
break
else:
print(2**(B//2)%(10**9+7)) |
s075400817 | p03848 | u368780724 | 1543633310 | Python | Python (3.4.3) | py | Runtime Error | 79 | 14692 | 339 | def inpl(): return [int(i) for i in input().split()]
import sys
N = int(input())
A = inpl()
H = dict([])
if N%2:
H[0] = -1
for i in range(1, 1+N//2):
H[2*i] = -2
else:
for i in range(1, 1+N//2):
H[2*i-1] = -2
for i in A:
H[i] += 1
H = list(H.values())
if any(H):
print(0)
sys.exit()
print(2**(N//2)) |
s560917485 | p03848 | u785989355 | 1541133122 | Python | Python (3.4.3) | py | Runtime Error | 26 | 10420 | 1132 |
def power(N):
ans=1
for i in range(N):
ans=(ans*2)%(10**9+7)
return ans
N=int(input())
A = map(int,input().split())
flag=True
if N%2==0:
n = [0 for i in range(N/2)]
for a in A:
if a%2==0:
print(0)
flag=False
break
if (a-1)/2 in range(N/2):
n[(a-1)/2]+=1
if n[(a-1)/2]==3:
print(0)
flag=False
break
else:
print(0)
flag=False
break
if flag:
print(power(N/2))
else:
n = [0 for i in range((N+1)/2)]
for a in A:
if a%2==1:
print(0)
flag=False
break
if a/2 in range((N+1)/2):
n[a/2]+=1
if a==0:
if n[a]==2:
print(0)
flag=False
break
elif n[a/2]==3:
print(0)
flag=False
break
else:
print(0)
flag=False
break
if flag:
print(power((N-1)/2))
|
s434999877 | p03848 | u667024514 | 1537571880 | Python | Python (3.4.3) | py | Runtime Error | 34 | 10740 | 350 | import math
n = int(input())
lis = list(map(str,input().split()))
li = [0 for _ in range(math.ceil(n / 2))]
for i in range(n):
li[math.floor(lis[i] / 2)] += 1
for i in range(len(li)):
if n % 2 == 1 and i == 0:
if li[i] != 1:
print("0")
exit()
else:
if li[i] != 2:
print("0")
exit()
print(2 ** (math.floor(n/2))) |
s247060986 | p03848 | u536113865 | 1536612561 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 275 | mod = 10**9+7
n = int(input())
a = sorted(f())
if n&1:
if all([a[i] == i+i%2 for i in range(n)]):
print(1<<((n-1)//2)%mod)
else:
print(0)
else:
if all([a[i] == i+(i+1)%2 for i in range(n)]):
print(1<<(n//2)%mod)
else:
print(0) |
s163904873 | p03848 | u698479721 | 1531509072 | Python | Python (3.4.3) | py | Runtime Error | 164 | 14008 | 525 | import sys
def coun(n):
if n == 0:
return 1
else:
return (2*coun(n-1))%(10**9+7)
N = int(input())
A = list(map(int, input().split()))
A.sort()
if len(A)%2 == 1:
if A[0]!=0:
print(0)
sys.exit()
i = 1
while i <= len(A)//2:
if A[2*i-1]==2*i and A[2*i]==2*i:
i += 1
else:
print(0)
sys.exit()
print(coun(N//2))
if len(A)%2 == 0:
i = 0
while i < N//2:
if A[2*i] == 2*i+1 and A[2*i+1] == 2*i+1:
i += 1
else:
print(0)
sys.exit()
print(coun(N//2)) |
s337570381 | p03848 | u835482198 | 1500847533 | Python | Python (3.4.3) | py | Runtime Error | 57 | 16620 | 445 | from collections import Counter
N = int(input())
A = map(int, input().split())
# N = 5
# A = [2, 4, 4, 0, 2]
mod = 10 ** 9 + 7
cnt = Counter(A)
if N % 2 == 0:
if len(filter(lambda c: c == 2, cnt.values())) != 0:
print(0)
else:
print(2 ** (N // 2))
else:
if cnt[0] != 1:
print(0)
cnt.pop(0)
if len(filter(lambda c: c == 2, cnt.values())) != 0:
print(0)
else:
print(2 ** (N // 2))
|
s556352649 | p03848 | u667084803 | 1494794552 | Python | Python (3.4.3) | py | Runtime Error | 112 | 16612 | 448 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
# ans=2**(N/2)
print(int(ans)%(10**9+7))
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
# ans=2**((N-1)/2)
print(int(ans)%(10**9+7))
else:
print(0) |
s635130620 | p03848 | u667084803 | 1494794522 | Python | Python (3.4.3) | py | Runtime Error | 111 | 16228 | 448 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
ans=2**(N/2)
# print(int(ans)%(10**9+7))
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
ans=2**((N-1)/2)
# print(int(ans)%(10**9+7))
else:
print(0) |
s489981347 | p03848 | u667084803 | 1494794490 | Python | Python (3.4.3) | py | Runtime Error | 111 | 16228 | 446 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
ans=2**(N/2)
print(int(ans)%(10**9+7))
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
ans=2**((N-1)/2)
print(int(ans)%(10**9+7))
else:
print(0) |
s093776439 | p03848 | u667084803 | 1494794420 | Python | Python (3.4.3) | py | Runtime Error | 109 | 16228 | 446 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
ans=2**(N/2)%(10**9+7)
print(int(ans))
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
ans=2**((N-1)/2)%(10**9+7)
print(int(ans))
else:
print(0) |
s098185809 | p03848 | u667084803 | 1494794362 | Python | Python (3.4.3) | py | Runtime Error | 112 | 16228 | 434 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
ans=int(2**(N/2))%(10**9+7)
print(ans)
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
print(int(2**((N-1)/2))%(10**9+7))
else:
print(0) |
s708172561 | p03848 | u667084803 | 1494794294 | Python | Python (3.4.3) | py | Runtime Error | 111 | 16612 | 246 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
print(int(2**(N/2))%(10**9+7))
else:
print(0) |
s182967787 | p03848 | u667084803 | 1494792445 | Python | Python (3.4.3) | py | Runtime Error | 115 | 16228 | 422 | N=int(input())
A=list(map(int,input().split()))
A.sort()
B=[]#偶数だけ
C=[]#奇数だけ
if N%2==0:
for i in range(0,int(N/2)):
B+=[2*i,2*i]
C+=[2*i+1,2*i+1]
if A==B or A==C:
print(int(2**(N/2))%(10**9+7))
else:
print(0)
else:
B+=[0]
C+=[1]
for i in range(0,int(N/2)):
B+=[2*i+2,2*i+2]
C+=[2*i+3,2*i+3]
if A==B or A==C:
print(int(2**((N-1)/2))%(10**9+7))
else:
print(0) |
s116027006 | p03848 | u536658633 | 1490753944 | Python | Python (3.4.3) | py | Runtime Error | 54 | 13880 | 1380 | N = int(input())
report_list = [int(n) for n in input().split()]
M = len(set(report_list))
def how_many_num_in_list(list, num):
count = 0
for element in list:
if element == num:
count += 1
return count
# 同じ数字が2個ずつあるか
# def is_ready_for_solve(list):
# if N % 2 == 0:
# c = 0
# for n in set(report_list):
# if how_many_num_in_list(report_list, n) == 2:
# c += 1
# if c == N / 2:
# return True
# else:
# return False
#
# else:
# c = 0
# for n in set(report_list):
# if n == 0:
# continue
# elif how_many_num_in_list(report_list, n) == 2:
# c += 1
# if c == (N - 1) / 2:
# return True
# else:
# return False
if N % 2 == 0:
if how_many_num_in_list(report_list, 0) == 0:
# if is_ready_for_solve(report_list):
if N == M * 2:
print(int((2 ** (N / 2)) % (10 ** 9 + 7)))
else:
print(0)
else:
print(0)
else:
if how_many_num_in_list(report_list, 0) == 1:
# if is_ready_for_solve(report_list):
if N - 1 == (M - 1) * 2:
print(int((2 ** ((N - 1) / 2)) % (10 ** 9 + 7)))
else:
print(0)
else:
print(0) |
s526673692 | p03848 | u422590714 | 1490749442 | Python | Python (3.4.3) | py | Runtime Error | 100 | 13880 | 589 | n = int(input())
lst = [int(e) for e in input().split(' ')]
lst = sorted(lst)
valid_list = []
if n % 2 == 1:
# 奇数
valid_list.append(0)
for i in range(1, int((n + 1) / 2)):
valid_list.append(i * 2)
valid_list.append(i * 2)
if lst == valid_list:
print(int(2 ** (((n - 1) / 2)) % 1000000007))
else:
print(0)
else:
for i in range(1, int((n / 2) + 1)):
valid_list.append((i * 2) - 1)
valid_list.append((i * 2) - 1)
if lst == valid_list:
print(int(2 ** ((n / 2)) % 1000000007))
else:
print(0)
|
s004258361 | p03848 | u422590714 | 1490747525 | Python | Python (3.4.3) | py | Runtime Error | 100 | 13880 | 630 | n = int(input())
lst = [int(e) for e in input().split(' ')]
lst = sorted(lst)
valid_list = []
if n % 2 == 1:
# 奇数
valid_list.append(0)
for i in range(1, int((n + 1) / 2)):
valid_list.append(i * 2)
valid_list.append(i * 2)
if lst == valid_list:
print((2 ** (((n - 1) / 2) / 5) % 1000000007) ** 5 % 1000000007)
else:
print(0)
else:
for i in range(1, int((n / 2) + 1)):
valid_list.append((i * 2) - 1)
valid_list.append((i * 2) - 1)
if lst == valid_list:
print(int(2 ** ((n / 2) / 5) % 1000000007) ** 5 % 1000000007)
else:
print(0)
|
s804251079 | p03848 | u422590714 | 1490746750 | Python | Python (3.4.3) | py | Runtime Error | 99 | 13880 | 589 | n = int(input())
lst = [int(e) for e in input().split(' ')]
lst = sorted(lst)
valid_list = []
if n % 2 == 1:
# 奇数
valid_list.append(0)
for i in range(1, int((n + 1) / 2)):
valid_list.append(i * 2)
valid_list.append(i * 2)
if lst == valid_list:
print(int(2 ** (((n - 1) / 2)) % 1000000007))
else:
print(0)
else:
for i in range(1, int((n / 2) + 1)):
valid_list.append((i * 2) - 1)
valid_list.append((i * 2) - 1)
if lst == valid_list:
print(int(2 ** ((n / 2)) % 1000000007))
else:
print(0)
|
s562957845 | p03848 | u598167418 | 1484797602 | Python | Python (2.7.6) | py | Runtime Error | 152 | 11504 | 862 | from collections import Counter
n = input()
a = [int(x) for x in raw_input().split()]
a.sort()
c = 0
if n&1:
if a[0] == 0:
del a[0]
d = Counter(a)
for i in d.keys():
if i == 0:
print 0
exit(1)
if i&1:
print 0
exit(1)
if not(i&1):
if d[i] == 2:
c += 1
if d[i] != 2:
print 0
exit(1)
if c == (n-1)//2:
print (1 << c)%(10**9+7)
if not(n&1):
d = Counter(a)
for i in d.keys():
if i&1:
if d[i] == 2:
c +=1
if d[i] != 2:
print 0
exit(1)
if not(i&1):
print 0
exit(1)
if c == n//2:
print (1 << c)%(10**9+7)
|
s940034262 | p03848 | u541568482 | 1483402587 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 386 | import sys
cin = sys.stdin
cin = open("in.txt", "r")
MODULO = int(10**9+7)
N = int(cin.readline())
A = list(map(int, cin.readline().split()))
pos = [0]*(N)
if (N%2==1):
pos[N//2+1]=1
for ai in A:
if (ai+N)%2==0:
print(0)
exit()
pos[ai]+=1
if pos[ai]>2:
print(0)
exit()
cnt = 1
for i in range(N//2):
cnt = cnt * 2 % MODULO
print(cnt) |
s272377985 | p03848 | u942033906 | 1483155555 | Python | Python (2.7.6) | py | Runtime Error | 23 | 4496 | 514 | N = int(input())
A = list(map(int,input().split()))
MOD = 10**9 + 7
def calc(a):
if 0 in a:
if a.count(0) != 1:
return 0
for i in [x*2 for x in range(1,int(N/2) + 1)]:
if a.count(i) != 2:
return 0
else:
for i in [x*2 - 1 for x in range(1,int(N/2) + 1)]:
if a.count(i) != 2:
return 0
return 2 ** int(N/2)
if N % 2 is 0:
if len(filter(lambda n:n%2==0, A)) > 0:
print(0)
else:
print(calc(A) % MOD)
else:
if len(filter(lambda n:n%2==1, A)) > 0:
print(0)
else:
print(calc(A) % MOD) |
s647695532 | p03848 | u942033906 | 1483155487 | Python | Python (3.4.3) | py | Runtime Error | 60 | 14008 | 514 | N = int(input())
A = list(map(int,input().split()))
MOD = 10**9 + 7
def calc(a):
if 0 in a:
if a.count(0) != 1:
return 0
for i in [x*2 for x in range(1,int(N/2) + 1)]:
if a.count(i) != 2:
return 0
else:
for i in [x*2 - 1 for x in range(1,int(N/2) + 1)]:
if a.count(i) != 2:
return 0
return 2 ** int(N/2)
if N % 2 is 0:
if len(filter(lambda n:n%2==0, A)) > 0:
print(0)
else:
print(calc(A) % MOD)
else:
if len(filter(lambda n:n%2==1, A)) > 0:
print(0)
else:
print(calc(A) % MOD) |
s092535558 | p03848 | u513091050 | 1482365168 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2696 | 735 | # -*- coding: utf-8 -*-
import sys
def maybe_check(n,A):
try:
if n <= 0 or n >= 10000:
raise
if len(A) <= 0 or len(A) > n:
raise
div = 10 ** 9 + 7
maybe_list = []
for i in range(1, n+1):
left = abs(i - n)
right = (n -1 )- left
maybe_list.append(abs(left - right))
pattern = len(set([x for x in maybe_list if maybe_list.count(x) != 1]))
for i in A:
if i in maybe_list:
maybe_list.remove(i)
else:
raise
return (2 ** pattern) % div
except:
return 0
args = sys.argv
_n = int(args[1])
_A = map(int,args[2:])
print maybe_check(_n,_A)
|
s365409258 | p03848 | u513091050 | 1482364873 | Python | Python (2.7.6) | py | Runtime Error | 18 | 2696 | 671 | # -*- coding: utf-8 -*-
import sys
def maybe_check(n,A):
if n <= 0 or n >= 10000:
return False
if len(A) <= 0 or len(A) > n:
print len(A),n-1
return False
div = 10 ** 9 + 7
maybe_list = []
for i in range(1, n+1):
left = abs(i - n)
right = (n -1 )- left
maybe_list.append(abs(left - right))
pattern = len(set([x for x in maybe_list if maybe_list.count(x) != 1]))
for i in A:
if i in maybe_list:
maybe_list.remove(i)
else:
return 0
return (2 ** pattern) % div
args = sys.argv
_n = int(args[1])
_A = map(int,args[2:])
print maybe_check(_n,_A)
|
s416410825 | p03848 | u513091050 | 1482364787 | Python | Python (2.7.6) | py | Runtime Error | 16 | 2696 | 663 | # -*- coding: utf-8 -*-
import sys
def maybe_check(n,A):
if n <= 0 or n >= 10000:
return False
if len(A) <= 0 or len(A) > n:
print len(A),n-1
return False
maybe_list = []
for i in range(1, n+1):
left = abs(i - n)
right = (n -1 )- left
maybe_list.append(abs(left - right))
pattern = len(set([x for x in maybe_list if maybe_list.count(x) != 1]))
for i in A:
if i in maybe_list:
maybe_list.remove(i)
else:
return 0
return (2 ** pattern) % div
args = sys.argv
n = int(args[1])
A = map(int,args[2:])
div = 10 ** 9 + 7
print maybe_check(n,A)
|
s036910855 | p03848 | u513091050 | 1482364133 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2696 | 529 | # -*- coding: utf-8 -*-
import sys
def maybe_check(A,n):
maybe_list = []
for i in range(1, n+1):
left = abs(i - n)
right = (n -1 )- left
maybe_list.append(abs(left - right))
pattern = len(set([x for x in maybe_list if maybe_list.count(x) != 1]))
for i in A:
if i in maybe_list:
maybe_list.remove(i)
else:
return 0
return (2 ** pattern) % div
args = sys.argv
n = int(args[1])
A = map(int,args[2:])
div = 10 ** 9 + 7
print maybe_check(A, n) |
s756966186 | p03848 | u513091050 | 1482363916 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2568 | 506 | import sys
def maybe_check(A,n):
maybe_list = []
for i in range(1, n+1):
left = abs(i - n)
right = (n -1 )- left
maybe_list.append(abs(left - right))
pattern = len(set([x for x in maybe_list if maybe_list.count(x) != 1]))
for i in A:
if i in maybe_list:
maybe_list.remove(i)
else:
return 0
return (2 ** pattern) % div
args = sys.argv
n = int(args[1])
A = map(int,args[2:])
div = 10 ** 9 + 7
print maybe_check(A, n)
|
s846436020 | p03849 | u089230684 | 1585467398 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 821 | n,m,q = input().split(" ")
n1=int(n/2)
m1=(m/2)
for i in range(int(q)):
a,b,c,d = input().split(" ")
a = int(a)
b= int(b)
c = int(c)
d=int(d)
if(a==1 and c==2):
if((b<=n1 and d<=m1) or (b>n1 and d>m1)):
print("YES")
else:
print("NO")
if(a==2 and c==1):
if((b<=m1 and d<=n1) or (b>m1 and d>n1)):
print("YES")
else:
print("NO")
if(a==1 and c==1):
if((b<=n1 and d<=n1) or (b>n1 and d>n1)):
print("YES")
else:
print("NO")
if(a==2 and c==2):
if((b<=m1 and d<=m1) or (b>m1 and d>m1)):
print("YES")
else:
print("NO")
|
s344245910 | p03849 | u388927326 | 1548586703 | Python | Python (3.4.3) | py | Runtime Error | 1741 | 6244 | 473 | #!/usr/bin/env python3
MOD = 10 ** 9 + 7
IMAX = 70
JMAX = 10 ** 5
def dp(n):
assert n <= JMAX
dp = [0 for j in range(JMAX + 1)]
dp[0] = 1
for i in reversed(range(IMAX + 1)):
d = 2 ** i
for j in reversed(range(JMAX + 1)):
if j - d >= 0:
dp[j] += dp[j - d]
if j - 2 * d >= 0:
dp[j] += dp[j - 2 * d]
return sum(dp[:n + 1])
def main():
n = int(input())
print(dp(n))
main()
|
s440384736 | p03849 | u054106284 | 1546110163 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 332 | N= int(input())
bit = bin(N)[2:]
k = len(bit)
dp = [[0] * 2 for i in range(len(bit) + 1)]
for i in range(k):
j = int(bit[k-i+1])
a,b,c = [(1,0,0),(1,1,0)][j]
d,e,f = [(2, 1, 1),(1, 2, 2)][j]
dp[i+1][0] = a * dp[i][0] + b * dp[i][1] + c * 3**i
dp[i+1][1] = d * dp[i][0] + e * dp[i][1] + f * 3**i
print(dp[k][0])
|
s817773713 | p03849 | u054106284 | 1546099401 | Python | Python (3.4.3) | py | Runtime Error | 78 | 3952 | 300 | N= int(input())
def b(N):
if N < 2:
res = N
else:
if N % 2 == 0:
res = b(N//2)
else:
res = b( (N-1)//2 ) + b( (N+1)//2 )
return res
def a(N):
if N > 0:
res = a(N-1)
else:
res = 0
return res + b(N+1)
print(a(N)) |
s410706974 | p03849 | u942033906 | 1483164402 | Python | Python (2.7.6) | py | Runtime Error | 17 | 2572 | 197 | N = int(raw_input())
#N = 1422
MOD = 10**9 + 7
l = [(a^b,a+b) for a in range(0,N+1) for b in range(a,N+1) if a+b <= N]
for u in range(0,N+1):
for a in range(0,N+1):
s = set(l)
print(len(s) % MOD)
|
s168084430 | p03850 | u347057617 | 1600207377 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9008 | 7380 | #include<bits/stdc++.h>
//using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,j,n) for(ll i=(ll)(j);i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(ll)(j);i<=(ll)(n);i++)
#define per(i,j,n) for(ll i=(ll)(j);(ll)(n)<=i;i--)
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(ll)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(ll)(key)))
#define pb emplace_back
#define mp std::make_pair
//
#define endl "\n"
//using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::upper_bound;
using std::lower_bound;
using vi=vector<ll>;
using vii=vector<vi>;
using pii=std::pair<ll,ll>;
//
constexpr ll MOD=1e9+7;
//constexpr ll MOD=998244353;
//constexpr ll MOD=10000000;
//constexpr ll MOD=1e4;
//constexpr ll MOD=1e5;
constexpr ll MAX=3e6;
constexpr ll inf=(1ll<<60);
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template<typename T>
struct Segment_tree{
ll N;
T mem;
vector<T> node;
Segment_tree(vector<T> &X,T m):mem(m){
ll sz=X.size();
N=1;
while(N<sz) N*=2;
node.resize(2*N-1,mem);
rep(i,0,sz) node[N-1+i]=X[i];
per(i,N-2,0){
node[i]=Compare(node[i*2+1],node[i*2+2]);
}
}
T Compare(T &A,T &B){
return std::max(A,B);
}
void update(ll X,T val){
X+=N-1;
node[X]=val;
while(X>0){
X=(X-1)/2;
node[X]=Compare(node[X*2+1],node[X*2+2]);
}
}
T Query(ll a,ll b,ll now,ll l,ll r){ //[a,b),[l,r)
if(r<0) r=N;
if(r<=a||b<=l) return mem;
if(a<=l&&r<=b) return node[now];
auto vl=Query(a,b,now*2+1,l,(l+r)/2),vr=Query(a,b,now*2+2,(l+r)/2,r);
return Compare(vl,vr);
}
};
template<typename T>
struct lazy_Segment_tree{
int N;
vector<T> node,lazy;
T INF;
lazy_Segment_tree(vector<T> X,T Y):INF(Y){
N=1;
while(X.size()>N) N*=2;
node.resize(2*N-1,Y);
lazy.resize(2*N-1);
rep(i,0,X.size()) node[i+N-1]=X[i];
per(i,N-2,0) node[i]=compare(node[i*2+1],node[i*2+2]);
}
T compare(T X,T Y){
return std::max(X,Y);
}
T plus(T X,int l,int r){
return X;
}
void eval(int now,int l,int r){
if(lazy[now]==0) return;
node[now]+=lazy[now];
if(r-l>1){
lazy[now*2+1]+=plus(lazy[now],l,r);
lazy[now*2+2]+=plus(lazy[now],l,r);
}
lazy[now]=0;
}
void update(int a,int b,T add,int now=0,int l=0,int r=-1){
if(r<0) r=N;
eval(now,l,r);
if(b<=l||r<=a) return;
if(a<=l&&r<=b){
lazy[now]+=add;
eval(now,l,r);
}
else{
update(a,b,add,now*2+1,l,(r+l)/2);
update(a,b,add,now*2+2,(r+l)/2,r);
node[now]=compare(node[now*2+1],node[now*2+2]);
}
}
T Query(int a,int b,int now=0,int l=0,int r=-1){
if(r<0) r=N;
eval(now,l,r);
if(b<=l||r<=a) return INF;
if(a<=l&&r<=b) return node[now];
return compare(Query(a,b,now*2+1,l,(r+l)/2),Query(a,b,now*2+2,(r+l)/2,r));
}
};
struct Tree{
int N;
vii dp;
vi dist;
Tree(vii edge){
N=edge.size();
dp.resize(N);
dist.resize(N,-1);
for(int i=0;i<N;i++) dp[i].resize(30);
dist[0]=dp[0][0]=0;
std::queue<int> que;
que.push(0);
while(!que.empty()){
int now=que.front(); que.pop();
for(int i=0;i<edge[now].size();i++){
int next=edge[now][i];
if(dist[next]==-1){
dist[next]=dist[now]+1;
que.push(next);
dp[next][0]=now;
}
}
}
for(int i=1;i<30;i++){
for(int j=0;j<N;j++) dp[j][i]=dp[dp[j][i-1]][i-1];
}
}
int LCA(int X,int Y){
if(dist[X]<dist[Y]) std::swap(X,Y);
{
int Z=dist[X]-dist[Y];
for(int i=0;i<30;i++){
if(Z&(1<<i)){
X=dp[X][i];
}
}
}
if(X==Y) return X;
for(int i=29;i>=0;i--){
if(dp[X][i]!=dp[Y][i]){
X=dp[X][i];
Y=dp[Y][i];
}
}
return dp[X][0];
}
};
struct Binary_indexed_tree{
int N;
vi bit;
Binary_indexed_tree(int n):N(n){
bit.resize(N+1,0);
}
void add(int x,ll a){
for(x;x<=N;x+=(x&-x)) bit[x]+=a;
}
ll sum(int x){
ll ret=0;
for(x;x>0;x-=(x&-x)) ret+=bit[x];
return ret;
}
ll lower_bound(ll X){
if(sum(N)<X) return -1;
ll ret=0,memo=1,sum=0;
while(memo*2<=N) memo*=2;
while(memo>0){
if(memo+ret<=N&&sum+bit[memo+ret]<X){
sum+=bit[memo+ret];
ret+=memo;
}
memo/=2;
}
return ret+1;
}
};
struct Union_Find{
ll N;
vi par;
vi siz;
Union_Find(int n):N(n){
par.resize(N);
siz.resize(N,1);
rep(i,0,N) par[i]=i;
}
ll root(ll X){
if(par[X]==X) return X;
return par[X]=root(par[X]);
}
bool same(ll X,ll Y){
return root(X)==root(Y);
}
void unite(ll X,ll Y){
X=root(X);
Y=root(Y);
if(X==Y) return;
par[X]=Y;
siz[Y]+=siz[X];
siz[X]=0;
}
ll size(ll X){
return siz[root(X)];
}
};
long long modpow(long long a, long long n, long long mod) {
long long res = 1;
while (n > 0) {
if (n & 1) res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
vi fac,finv,inv;
void COMinit() {
fac.resize(MAX);
finv.resize(MAX);
inv.resize(MAX);
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(ll n,ll r){
if(n<r||n<0||r<0) return 0;
return fac[n]*finv[r]%MOD*finv[n-r]%MOD;
}
void comp(vi &A){
std::map<ll,ll> memo;
rep(i,0,A.size()) memo[A[i]]=0;
ll cnt=1;
for(auto &p:memo) p.second=cnt++;
rep(i,0,A.size()) A[i]=memo[A[i]];
}
void dec(std::map<ll,ll> &mem,ll X){
mem[X]--;
if(mem[X]==0) mem.erase(X);
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll N; cin>>N;
vi A(N);
vector<char> op(N);
rep(i,0,N-1) cin>>A[i]>>op[i];
cin>>A[N-1];
vii dp(N,vi(3,-inf));
dp[0][0]=A[0];
rep(i,1,N){
if(op[i-1]=='+'){
dp[i][0]=std::max({dp[i-1][0],dp[i-1][1],dp[i-1][2]})+A[i];
dp[i][1]=dp[i-1][1]-A[i];
dp[i][2]=dp[i-1][2]+A[i];
}
else{
dp[i][0]=dp[i-1][0]-A[i];
dp[i][1]=std::max(dp[i-1][0]-A[i],dp[i-1][1]+A[i]);
dp[i][2]=std::max(dp[i-1][2]+A[i],dp[i-1][1]+A[i]);
}
}
ll ans=-inf;
rep(i,0,3) ans=std::max(ans,dp[N-1][i]);
cout<<ans<<endl;
}
|
s967943705 | p03850 | u368780724 | 1553312412 | Python | PyPy3 (2.4.0) | py | Runtime Error | 625 | 136896 | 278 | N = int(input())
M = list(input().split())
mini = 0
ans = 0
for s in M:
if s == '-':
mini += 1
elif s == '+':
pass
else:
s = int(s)
if mini == 1:
ans -= s
else:
ans += s
print(max(ans,eval(''.join(M)))) |
s490342278 | p03850 | u039623862 | 1482121465 | Python | Python (3.4.3) | py | Runtime Error | 71 | 16276 | 468 | n = int(input())
ipt = input().split()
a = [int(ipt[i]) for i in range(0, 2*n+1,2)] + [0]
opr = [''] + [ipt[i] for i in range(1, 2*n, 2)] + ['-']
max_v = a[0]
for i in range(1,n):
if opr[i] == '+':
max_v += a[i]
else:
max_v -= a[i]
s = sum(a)
cur = 0
for i in range(1,n+1):
if opr[i] == '-':
if cur != 0:
max_v = max(max_v, s-2*cur)
cur = a[i]
else:
if cur != 0:
cur += a[i]
print(max_v) |
s893799713 | p03850 | u039623862 | 1482121389 | Python | Python (3.4.3) | py | Runtime Error | 69 | 16272 | 468 | n = int(input())
ipt = input().split()
a = [int(ipt[i]) for i in range(0, 2*n+1,2)] + [0]
opr = [''] + [ipt[i] for i in range(1, 2*n, 2)] + ['-']
max_v = a[0]
for i in range(1,n):
if opr[i] == '+':
max_v += a[i]
else:
max_v -= a[i]
s = sum(a)
cur = 0
for i in range(1,n+1):
if opr[i] == '-':
if cur != 0:
max_v = max(max_v, s-2*cur)
cur = a[i]
else:
if cur != 0:
cur += a[i]
print(max_v) |
s402348232 | p03850 | u039623862 | 1482119084 | Python | Python (3.4.3) | py | Runtime Error | 45 | 14164 | 363 | n = int(input())
ipt = input().split()
node = [int(ipt[0])]
plus = n
while plus > 1 and ipt[2*plus-1] == '+':
node[0] += int(ipt[2*plus])
plus -= 1
for i in range(plus):
if ipt[2*i+1] == '+':
node[-1] += int(ipt[2*i+2])
else:
node.append(int(ipt[2*i+2]))
if len(node) == 1:
print(node[0])
else:
print(sum(node) - 2*node[1]) |
s252649941 | p03850 | u380653557 | 1482115134 | Python | Python (3.4.3) | py | Runtime Error | 301 | 44936 | 710 | import sys
n = int(next(sys.stdin).strip())
items = next(sys.stdin).strip().split()
cache = {(i, i + 1): (int(items[2 * i]), int(items[2 * i])) for i in range(n)}
def value(l, r):
if (l, r) in cache:
return cache[(l, r)]
lower, upper = float('inf'), float('-inf')
for c in range(l + 1, r):
ll, lu = value(l, c)
rl, ru = value(c, r)
op = items[2 * c - 1]
if op == '+':
lower = min(lower, ll + rl)
upper = max(upper, lu + ru)
elif op == '-':
lower = min(lower, ll - ru)
upper = max(upper, lu - rl)
cache[(l, r)] = (lower, upper)
return lower, upper
lower, upper = value(0, n)
print(upper)
|
s357909908 | p03850 | u380653557 | 1482114347 | Python | Python (3.4.3) | py | Runtime Error | 291 | 44848 | 675 | import sys
n = int(next(sys.stdin).strip())
items = next(sys.stdin).strip().split()
cache = {(i, i + 1): (int(items[2 * i]), int(items[2 * i])) for i in range(n)}
def value(l, r):
if (l, r) in cache:
return cache[(l, r)]
lower, upper = float('inf'), float('-inf')
for c in range(l + 1, r):
ll, lu = value(l, c)
rl, ru = value(c, r)
op = items[2 * c - 1]
if op == '+':
lower = min(lower, ll + rl)
upper = max(upper, lu + ru)
elif op == '-':
lower = min(lower, ll - ru)
upper = max(upper, lu - rl)
return lower, upper
lower, upper = value(0, n)
print(upper)
|
s075046398 | p03852 | u137226361 | 1600232799 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9056 | 666 | N, K, L = map(int, input().split())
par = [i for i in range(N)]
size = [1] * N
def find(x, P):
if P[x] == x:
return x
else:
return find(P[x], P)
def unite(x, y):
x = find(x, par)
y = find(y, par)
if x != y:
# xとyの属している集合が異なる時
pass
#par[x] = y
par2 = [i for i in range(N)]
def unite2(x, y):
x = find(x, par2)
y = find(y, par2)
if x != y:
# xとyの属している集合が異なる時
par2[x] = y
s = size[x] + size[y]
size[y] = s
for _ in range(K):
p, q = map(int, input().split())
find(q-1, par)
unite(p-1, q-1) |
s489234322 | p03852 | u987988155 | 1600114592 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8840 | 71 | C = c
if c == a,e,i,o,u :
print("vowel")
else :
print("consonant") |
s868709729 | p03852 | u492910842 | 1599339236 | Python | PyPy3 (7.3.0) | py | Runtime Error | 93 | 74524 | 99 | a=input()
if a="a" or a="i" or a="u" or a="e" or a="o":
print("vowel")
else:
print("consonant") |
s746908021 | p03852 | u904995051 | 1599328779 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8960 | 74 | c = input()
if c in "aeiou":
print("vowel")
else:
print("consonant") |
s928360820 | p03852 | u620846115 | 1598698705 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8832 | 99 | n = str(input())
if n = "a" or "i" or "u" or "e" or "o":
print("vowe")
else:
print("consonant") |
s856975018 | p03852 | u309120194 | 1598671067 | Python | Python (3.8.2) | py | Runtime Error | 25 | 8816 | 117 | c = int(input())
if c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o': print('vowel')
else: print('consonant') |
s807529364 | p03852 | u808569469 | 1598665852 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9044 | 64 | if c in "aiueo":
print("vowel")
else:
print("consonant") |
s011405155 | p03852 | u063596417 | 1597883752 | Python | Python (3.8.2) | py | Runtime Error | 29 | 9160 | 178 | def main():
h, _ = map(int, input().split())
c = [input() for _ in range(h)]
for cn in c:
print(cn)
print(cn)
if __name__ == "__main__":
main()
|
s486296071 | p03852 | u798260206 | 1597751960 | Python | Python (3.8.2) | py | Runtime Error | 20 | 8964 | 103 | a = input()
vowel = set("a","b","c","d","e")
if a in vowel:
print("vowel")
else:
print("consonant") |
s117105949 | p03852 | u070200692 | 1597608813 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9020 | 77 | x = 'aeiou'
i = input()
if i in x:
print("vowel")
else
print("consonant") |
s460100292 | p03852 | u068646483 | 1597596149 | Python | PyPy3 (7.3.0) | py | Runtime Error | 98 | 74776 | 106 | c = input()
if c == a or c == i or c == u or c == e or c == o:
print('vowel')
else:
print('consonant') |
s102525785 | p03852 | u539616549 | 1597585612 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8684 | 217 | #include <bits/stdc++.h>
using namespace std;
int main() {
char s;
cin >> s;
if (s=='a' or s=='i' or s=='u' or s=='e' or s=='o') {
cout << "vowel" << endl;
} else {
cout << "consonant" << endl;
}
}
|
s892931942 | p03852 | u539616549 | 1597585489 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8944 | 215 | #include <bits/stdc++.h>
using namespace std;
int main() {
char s;
cin >> s;
if s=='a' or s=='i' or s=='u' or s=='e' or s=='o' {
cout << "vowel" << endl;
} else {
cout << "consonant" << endl;
}
}
|
s688060820 | p03852 | u539616549 | 1597585364 | Python | Python (3.8.2) | py | Runtime Error | 22 | 8944 | 214 | #include <bits/stdc++.h>
using nameplace std;
int main() {
char s;
cin >> s;
if s=='a' or s=='i' or s=='u' or s=='e' or s=='o' {
cout << "vowel" << endl;
} else {
cout << "consonant" << endl;
}
} |
s410727864 | p03852 | u250662864 | 1597509387 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8596 | 146 | letter = input()
if(letter == "a" or letter == "e" or letter = "i" or letter == "o" or letter == "u"):
print("vowel")
else:
print("consonant") |
s528845628 | p03852 | u921632705 | 1597265676 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8916 | 71 | N = input()
if N in "aiueo"
print("vowel")
else
print("consonant")
|
s569350085 | p03852 | u921632705 | 1597265640 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8988 | 83 | N = input()
if "a","e","i","o","u" in N
print("vowel")
else
print("consonant")
|
s000524336 | p03852 | u921632705 | 1597265612 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8956 | 73 | N = input()
if a,e,i,o,u in N
print("vowel")
else
print("consonant")
|
s366421695 | p03852 | u074220993 | 1597113177 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9028 | 116 | s = input()
if s == "a" or s == "i" or s == "u" or s == "e" or s == "o":
print(vowel)
else:
print(consonant) |
s811404112 | p03852 | u477696265 | 1597107887 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8912 | 217 | text = str(input())
if text == a
print(vowel)
elif text == i
print(vowel)
elif text == u
print(vowel)
elif text == e :
print(vowel)
elif text == o ::
print=(vowel)
else:
print=(consonant) |
s278129255 | p03852 | u477696265 | 1597107384 | Python | Python (3.8.2) | py | Runtime Error | 27 | 8904 | 211 | text = input()
if text == 'a'
print(vowel)
elif text == i
print(vowel)
elif text == u
print(vowel)
elif text == e
print(vowel)
elif text == o
print=(vowel)
else:
print=(consonant) |
s365837591 | p03852 | u477696265 | 1597032274 | Python | Python (3.8.2) | py | Runtime Error | 26 | 8884 | 232 | text = input()
if (text == a )
print('vowel')
elif (text == i )
print('vowel')
elif (text == u )
print('vowel')
elif (text == e )
print('vowel')
elif (text == o )
print=('vowel')
else:
print=('consonant') |
s283777921 | p03852 | u477696265 | 1597032045 | Python | Python (3.8.2) | py | Runtime Error | 31 | 8992 | 231 | text = input()
if (text == 'a')
print('vowel')
elif (text == 'i')
print('vowel')
elif (text == 'u')
print('vowel')
elif (text == 'e')
print('vowel')
elif (text == 'o')
print('vowel')
else:
print('consonant') |
s265296137 | p03852 | u442948527 | 1596684747 | Python | Python (3.8.2) | py | Runtime Error | 24 | 8956 | 82 | s=input()
print(["vowel","consonant"][s="a" or s="i" or s="u" or s="e" or s="o"])
|
s634976152 | p03852 | u125269142 | 1596575688 | Python | Python (3.8.2) | py | Runtime Error | 22 | 9008 | 127 | s = input()
if s == 'a' or s == 'i' or s == 'u' or s == 'e' or s == 'o':
ans = 'vowel'
else:
ans = 'consonant"
print(ans) |
s462058267 | p03852 | u891847179 | 1596259763 | Python | Python (3.8.2) | py | Runtime Error | 19 | 8884 | 89 | c = input()
if c in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else
print('consonant')
|
s879294849 | p03852 | u891847179 | 1596259718 | Python | Python (3.8.2) | py | Runtime Error | 21 | 8868 | 90 | c = input()
if c in ['a', 'i', 'u', 'e', 'o']:
print('vowel')
else
print('consonant')
|
s362062659 | p03852 | u388297793 | 1596238725 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9028 | 82 | c=input()
x=[a,e,i,o,u]
if x in c:
print("vowel")
else:
print("consonant") |
s043712736 | p03852 | u099212858 | 1595979748 | Python | Python (3.8.2) | py | Runtime Error | 23 | 8960 | 116 | x = str(input())
if x = "a" or x = "i" or x = "u" or x = "e" or x = "o":
print("vowel")
else:
print("consonant") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.