Submission #1444273
Source Code Expand
#include <bits/stdc++.h> #define debug(x) cerr<< #x << ": "<< x << endl; #define print(x) cerr<< x << endl; #define mp make_pair #define pb push_back #define all(x) (x).begin() , (x).end() #define rall(x) (x).rbegin() , (x).rend() #define REP(i,x,y) for(int i=x;i<y;i++) #define REPIT(it,A) for(typeof(A.begin()) it = (A.begin()); it!=A.end();it++) #define fst first #define snd second #define sqr(x) ((x)*(x)) #define fastio ios_base::sync_with_stdio(0);cin.tie(0); #define ones(x) __builtin_popcountll(x) using namespace std; typedef pair<int,int> ii ; typedef long long ll ; typedef vector<int> vi; typedef vector<ii> vii; int a[55], n, p; ll dp[55][2]; ll go(int pos, int m){ if(pos == n){ return m == p; } if(dp[pos][m] != -1) return dp[pos][m]; ll val = go(pos + 1, (m + a[pos]) % 2) + go(pos + 1, m); return dp[pos][m] = val; } int main(){ fastio; cin >> n >> p; REP(i,0,n) cin >> a[i]; REP(i,0,55) REP(j,0,2) dp[i][j] = -1; ll res = go(0,0); cout<<res<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Biscuits |
User | Jael |
Language | C++14 (GCC 5.4.1) |
Score | 200 |
Code Size | 1049 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 |