QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793139#9798. Safety FirstLGyxjTL 0ms0kbC++141.6kb2024-11-29 17:09:092024-11-29 17:09:10

Judging History

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

  • [2024-11-29 17:09:10]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-11-29 17:09:09]
  • 提交

answer

//////////////////////////
// Author: lnyxj
// Time: 2024-11-27 10:48:38
///////////////////////////
// #pragma target("avx,avx2")
#include <bits/stdc++.h>
#define xx first
#define yy second
// #define int long long
// #define double long double
using namespace std;
const int N = 2000 + 3, M = 1e5 + 5, mod = 998244353, inv2 = mod + 1 >> 1, inf = 0x3f3f3f3f;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef long long ll;

int T;
int ans[M];
vector<pii> qst[N];

void init() {
	// T = 1;
	// qst[2000].push_back({2000, 1});
	cin >> T;
	for (int i = 1; i <= T; ++ i) {
		int n, m;
		cin >> n >> m;
		if (n == 1) ans[i] = 1;
		else qst[n].push_back({m, i});
	}
}

inline void Add(int& x, int y) { ((x += y) >= mod) && (x -= mod); }
// #define Add(x, y) (((x += y) >= mod) && (x -= mod))

void solve() {
	static int f[N][N];
	for (int j = 1; j < N; ++ j) 
		for (int i = j; i < N; ++ i) 
			f[j][i] = 1;
	for (int i = 2; i < N; ++ i) {
		// if (i % 512 == 0) cout << i << '\n' << flush;
		// const int cur = i & 1, las = cur ^ 1;
		// memset(f[cur], 0, sizeof f[cur]);
		for (int k = N - 1; k; -- k) {
			for (int j = N - 1 - k; j >= k; -- j) {
				// Add(f[cur][j][k], f[las][j][k]);
				Add(f[k][j + k], f[k][j]);
			}
		}
		for (int k = N - 1; k > 1; -- k) 
			for (int j = N - 1; j >= k; -- j) {
				Add(f[k - 1][j], f[k][j]);
		}
		for (auto [m, id] : qst[i]) 
			ans[id] = f[1][m];
	}
	for (int i = 1; i <= T; ++ i) cout << ans[i] << '\n';
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	init(); solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

3
1 3
2 3
3 3

output:


result: