52372023-04-23 16:27:00SleepyOverlordJáték (50 pont)cpp17Time limit exceeded 29/50168ms14304 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

const int MOD = 1e9 + 7;

int n, b, c;
vector <VVI> dp;

int main()
{
	cin >> b >> c;
	int n = c - b;

	dp.RS(2, VVI(n + 1, VI(2)));
	FOR(j, 0, n) dp[0][j][1] = 1;
	int now = 1;
	int sum = 1;
	FOR(i, 1, c)
	{
		FOR(j, 0, n)
		{
			dp[now][j][0] = 0;
			dp[now][j][1] = 0;
		}
		FOR(j, 0, n)
		{
			if (i - j >= b) continue;
			if (i > 0) dp[now][j][0] += dp[now ^ 1][j][0] + dp[now ^ 1][j][1];
			if (j > 0) dp[now][j][1] += dp[now][j - 1][0] + dp[now][j - 1][1];
			if (dp[now][j][0] >= MOD) dp[now][j][0] -= MOD;
			if (dp[now][j][1] >= MOD) dp[now][j][1] -= MOD;
		}
		sum = (sum + dp[now][n][1]) % MOD;
		now ^= 1;
	}

	cout << sum;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base29/50
1Accepted0/03ms1812 KiB
2Accepted0/03ms2008 KiB
3Accepted2/23ms2252 KiB
4Accepted3/33ms2468 KiB
5Accepted3/32ms2532 KiB
6Accepted3/34ms2680 KiB
7Accepted3/34ms2888 KiB
8Accepted3/312ms3024 KiB
9Accepted3/323ms3516 KiB
10Accepted3/318ms3592 KiB
11Accepted3/365ms3508 KiB
12Time limit exceeded0/3111ms3436 KiB
13Accepted3/361ms3460 KiB
14Time limit exceeded0/3163ms14304 KiB
15Time limit exceeded0/3164ms6576 KiB
16Time limit exceeded0/3159ms7272 KiB
17Time limit exceeded0/3168ms10464 KiB
18Time limit exceeded0/3167ms6692 KiB
19Time limit exceeded0/3167ms9372 KiB