Submission #1839955
Source Code Expand
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fi first #define se second #define mp make_pair #define pb push_back #define fbo find_by_order #define ook order_of_key typedef long long ll; typedef pair<ll,ll> ii; typedef vector<int> vi; typedef long double ld; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; typedef set<int>::iterator sit; typedef map<int,int>::iterator mit; typedef vector<int>::iterator vit; const int MOD = 1e9+7; int add(int a, int b) { a+=b; while(a>=MOD) a-=MOD; return a; } int mult(int a, int b) { return (a*1LL*b)%MOD; } int pow2[2111]; int dp[2111][2111]; int sum[2111][2111]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); pow2[0]=1; for(int i=1;i<=2011;i++){pow2[i]=add(pow2[i-1],pow2[i-1]);} int n,k; cin>>n>>k; if(n==1) { cout<<1<<'\n'; return 0; } int coeff=(k<n?pow2[n-k-1]:1); for(int i=1;i<=n-1;i++) dp[0][i]=1; for(int i=1;i<k;i++) { for(int j=n-i-1;j>=(i==n-1?0:1);j--) { if(j==n-i-1) dp[i][j]=dp[i-1][j+1]; else dp[i][j]=dp[i][j+1]; dp[i][j]=add(dp[i][j],dp[i-1][j]); } } int ans=dp[k-1][(k==n?0:1)]; ans=mult(ans,coeff); cout<<ans<<'\n'; }
Submission Info
Submission Time | |
---|---|
Task | F - Solitaire |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 1295 Byte |
Status | AC |
Exec Time | 18 ms |
Memory | 18688 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 2 ms | 2304 KB |
00_example_02.txt | AC | 2 ms | 2304 KB |
00_example_03.txt | AC | 13 ms | 10496 KB |
01.txt | AC | 2 ms | 2304 KB |
02.txt | AC | 6 ms | 8448 KB |
03.txt | AC | 2 ms | 2304 KB |
04.txt | AC | 2 ms | 2304 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 2 ms | 2304 KB |
07.txt | AC | 2 ms | 2304 KB |
08.txt | AC | 2 ms | 2304 KB |
09.txt | AC | 16 ms | 16640 KB |
10.txt | AC | 2 ms | 2304 KB |
11.txt | AC | 2 ms | 2304 KB |
12.txt | AC | 15 ms | 16640 KB |
13.txt | AC | 2 ms | 2304 KB |
14.txt | AC | 10 ms | 8448 KB |
15.txt | AC | 4 ms | 6400 KB |
16.txt | AC | 10 ms | 8448 KB |
17.txt | AC | 8 ms | 6400 KB |
18.txt | AC | 14 ms | 12544 KB |
19.txt | AC | 13 ms | 10496 KB |
20.txt | AC | 7 ms | 6400 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 18 ms | 18688 KB |
23.txt | AC | 2 ms | 2304 KB |