52362023-04-23 16:25:43SleepyOverlordJáték (50 pont)cpp17Futási hiba 14/5046ms63640 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(c + 1, VVI(n + 1, VI(2)));
	FOR(j, 0, n) dp[0][j][1] = 1;

	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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base14/50
1Elfogadva0/03ms1812 KiB
2Elfogadva0/07ms6280 KiB
3Elfogadva2/23ms2476 KiB
4Elfogadva3/33ms2504 KiB
5Elfogadva3/33ms2952 KiB
6Elfogadva3/317ms18564 KiB
7Elfogadva3/323ms25160 KiB
8Futási hiba0/346ms63640 KiB
9Futási hiba0/346ms63520 KiB
10Futási hiba0/341ms63484 KiB
11Futási hiba0/341ms63276 KiB
12Futási hiba0/346ms63240 KiB
13Futási hiba0/341ms63000 KiB
14Futási hiba0/341ms62988 KiB
15Futási hiba0/346ms62972 KiB
16Futási hiba0/346ms62728 KiB
17Futási hiba0/345ms62492 KiB
18Futási hiba0/343ms62468 KiB
19Futási hiba0/341ms62460 KiB