Submission #1084219


Source Code Expand

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <cassert>

using namespace std;

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
const int mod = int(1e9) + 7;
const long long infLL = 2e18;
const int MX = 2061;
int dp[MX][MX];
int main()
{
    //init();
    //cerr << delta << endl;
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    dp[0][n + 1] = 1;
    for(int i = 1; i < k; i++){
        for(int j = n - i + 1; j > 1; j--){
            if(j == n - i + 1) dp[i][j] = (dp[i - 1][j] + dp[i - 1][j + 1]) % mod; else
                            dp[i][j] = (dp[i - 1][j] + dp[i][j + 1]) % mod;
        }
    }
    int ans = 0;
    for(int j = 1; j <= n; j++){
        ans += dp[k - 1][j];
        ans %= mod;
    }
    if(k == 1) ans = 1;
    for(int i = 0; i < n - k - 1; i++){
        ans *= 2;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task F - Solitaire
User melnyk
Language C++14 (GCC 5.4.1)
Score 1200
Code Size 1142 Byte
Status AC
Exec Time 29 ms
Memory 14208 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 1200 / 1200
Status
AC × 3
AC × 26
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 3 ms 256 KB
00_example_02.txt AC 3 ms 256 KB
00_example_03.txt AC 20 ms 8320 KB
01.txt AC 3 ms 256 KB
02.txt AC 12 ms 5632 KB
03.txt AC 3 ms 384 KB
04.txt AC 3 ms 768 KB
05.txt AC 3 ms 256 KB
06.txt AC 3 ms 256 KB
07.txt AC 3 ms 256 KB
08.txt AC 3 ms 384 KB
09.txt AC 25 ms 12416 KB
10.txt AC 3 ms 256 KB
11.txt AC 3 ms 256 KB
12.txt AC 26 ms 12800 KB
13.txt AC 3 ms 512 KB
14.txt AC 15 ms 5632 KB
15.txt AC 6 ms 2688 KB
16.txt AC 15 ms 5760 KB
17.txt AC 13 ms 4608 KB
18.txt AC 23 ms 9984 KB
19.txt AC 21 ms 8832 KB
20.txt AC 11 ms 3968 KB
21.txt AC 3 ms 256 KB
22.txt AC 29 ms 14208 KB
23.txt AC 3 ms 256 KB