Submission #1409255
Source Code Expand
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define inf (1<<30)-1
#define INF (1LL<<62)-1
#define MOD 1000000007LL
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define PI acos(-1)
#define MEM(x,y) memset(x,y,sizeof (x))
#define debug cout<<"A"<<'\n'
#define REP(i,a,b) for (int i=(a); i<=(b); i++)
#define PER(i,a,b) for (int i=(a); i>=(b); i--)
#define REPL(i,a,b) for (LL i=(a); i<=(b); i++)
#define PERL(i,a,b) for (LL i=(a); i>=(b); i--)
#define print(x) cout<<x<<'\n'
#define itrALL(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define UNIQUE(X) X.erase( unique( X.begin(), X.end() ), X.end() )
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<LL,LL>PLL;
typedef vector<int> VI;
typedef vector<LL> VL;
// Order Statistic Tree
/* Special functions:
find_by_order(k) --> returns iterator to the kth largest element counting from 0
order_of_key(val) --> returns the number of items in a set that are strictly smaller than our item
*/
typedef tree<
PII,
null_type,
less<PII>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
template <class T> inline T bigmod(T p,T e,T M)
{
T ret = 1;
for(; e > 0; e >>= 1)
{
if(e & 1) ret = (ret * p) % M;
p = (p * p) % M;
} return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}
template <class T, class X> inline bool getbit(T a, X i) { T t=1; return ((a&(t<<i))>0);}
template <class T, class X> inline T setbit(T a, X i) { T t=1;return (a|(t<<i)); }
template <class T, class X> inline T resetbit(T a, X i) { T t=1;return (a&(~(t<<i)));}
/*end of header*/
LL n,p, a[52],ncr[52][52];
int main()
{
//freopen("input_file_name.in","r",stdin);
//freopen("output_file_name.out","w",stdout);
cin>>n>>p;
REP(i,1,n)cin>>a[i];
REP(i,0,n)
{
ncr[i][0]=ncr[i][i]=1;
REP(j,1,i-1)ncr[i][j]=ncr[i-1][j]+ncr[i-1][j-1];
}
LL cnt1=0, cnt0=0;
REP(i,1,n)
{
if(a[i]%2==1)cnt1++;
else cnt0++;
}
LL ans=0;
if(p==0)
{
for(int i=0;i<=cnt1;i+=2)ans+=ncr[cnt1][i];
}
else
{
for(int i=1;i<=cnt1;i+=2)ans+=ncr[cnt1][i];
}
REP(i,1,cnt0)ans*=2LL;
print(ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
A - Biscuits |
User |
comfi |
Language |
C++14 (GCC 5.4.1) |
Score |
200 |
Code Size |
2684 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
200 / 200 |
Status |
|
|
Set Name |
Test Cases |
Sample |
sample1.txt, sample2.txt, sample3.txt, sample4.txt |
All |
sample1.txt, sample2.txt, sample3.txt, sample4.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt |
Case Name |
Status |
Exec Time |
Memory |
in1.txt |
AC |
1 ms |
256 KB |
in2.txt |
AC |
1 ms |
256 KB |
in3.txt |
AC |
1 ms |
256 KB |
in4.txt |
AC |
1 ms |
256 KB |
in5.txt |
AC |
1 ms |
256 KB |
in6.txt |
AC |
1 ms |
256 KB |
in7.txt |
AC |
1 ms |
256 KB |
in8.txt |
AC |
1 ms |
256 KB |
sample1.txt |
AC |
1 ms |
256 KB |
sample2.txt |
AC |
1 ms |
256 KB |
sample3.txt |
AC |
1 ms |
256 KB |
sample4.txt |
AC |
1 ms |
256 KB |