QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808763#79. Fabricating SculpturesLaVuna47TL 2ms8036kbC++172.1kb2024-12-11 01:50:442024-12-11 01:50:44

Judging History

你现在查看的是最新测评结果

  • [2024-12-11 01:50:44]
  • 评测
  • 测评结果:TL
  • 用时:2ms
  • 内存:8036kb
  • [2024-12-11 01:50:44]
  • 提交

answer

/** gnu specific **/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
/** contains everything I need in std **/
#include <bits/stdc++.h>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(S) ((int)S.size())
#define FOR(i, st_, n) for(int i = st_; i < n; ++i)
#define RFOR(i, n, end_) for(int i = (n)-1; i >= end_; --i)
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef unsigned long long ull;
typedef long double LD;
typedef pair<ull, ull> pull;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
using namespace std;
#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

#define MAX_N 5010
ll dp[2][MAX_N][MAX_N][2];
const ll MOD=1e9+7;

int solve()
{
	int n,m;
	if(!(cin>>n>>m))
		return 1;
	m-=n;
	
	FOR(i,0,MAX_N)FOR(j,0,2)dp[0][0][i][j]=1;

	
	FOR(p,0,n)
	{
		FOR(st,0,m+1)
		{
			FOR(prev,0,m+1)
			{
				ll res=0;
				for(int i=0;st-prev-i>=0 && prev+i<MAX_N;++i)
					res += dp[p&1][st-prev-i][prev+i][true];
				
				for(int i=0;i <= prev-1 && i <= st;++i)
					res += dp[p&1][st-i][i][false];

				dp[(p+1)&1][st][prev][true]=res;
			}
			FOR(prev,0,MAX_N)
			{
				ll res=0;
				for(int i=0;i <= prev && st-i >= 0; ++i)
					res += dp[p&1][st-i][i][false];
				dp[(p+1)&1][st][prev][false]=res%MOD;
			}
		}
	}
	cout<<dp[n&1][m][0][true]<<'\n';
    return 0;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int TET = 1e9;
    //cin >> TET;
    for (int i = 1; i <= TET; i++)
    {
        if (solve())
        {
            break;
        }
#ifdef ONPC
        cout << "__________________________" << endl;
#endif
    }
#ifdef ONPC
    cerr << endl << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
#endif
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6052kb

input:

3 6

output:

8

result:

ok single line: '8'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5784kb

input:

2 3

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 5980kb

input:

3 5

output:

5

result:

ok single line: '5'

Test #4:

score: 0
Accepted
time: 0ms
memory: 5984kb

input:

4 6

output:

7

result:

ok single line: '7'

Test #5:

score: 0
Accepted
time: 1ms
memory: 8036kb

input:

5 7

output:

9

result:

ok single line: '9'

Test #6:

score: 0
Accepted
time: 1ms
memory: 5988kb

input:

6 8

output:

11

result:

ok single line: '11'

Test #7:

score: 0
Accepted
time: 1ms
memory: 6076kb

input:

6 9

output:

20

result:

ok single line: '20'

Test #8:

score: 0
Accepted
time: 2ms
memory: 6292kb

input:

4 10

output:

42

result:

ok single line: '42'

Test #9:

score: -100
Time Limit Exceeded

input:

2505 5000

output:


result: