QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#793160#9798. Safety FirstLGyxjWA 544ms7600kbC++202.0kb2024-11-29 17:20:562024-11-29 17:20:56

Judging History

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

  • [2024-11-29 17:20:56]
  • 评测
  • 测评结果:WA
  • 用时:544ms
  • 内存:7600kb
  • [2024-11-29 17:20:56]
  • 提交

answer

//////////////////////////
// Author: lnyxj
// Time: 2024-11-27 10:48:38
///////////////////////////
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma target("avx,avx2")
// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#define xx first
#define yy second
// #define int long long
// #define double long double
using namespace std;
const int N = 1000 + 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() {
	#ifdef LOCALDEBUG
		T = 1;
		qst[2000].push_back({2000, 1});
	#else
		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});
		}
	#endif
}

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 j = 0; j < qst[i].size(); ++ j) 
			// ans[qst[i][j].yy] = f[1][qst[i][j].xx];
		// for (const pii& a : qst[i]) 
			// ans[a.yy] = f[1][a.xx];
	}
	for (int i = 1; i <= T; ++ i) cout << ans[i] << '\n';
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifdef LOCALDEBUG
		const int t1 = clock();
	#endif
	init(); solve();
	#ifdef LOCALDEBUG
		cerr << clock() - t1 << '\n';
	#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 543ms
memory: 7576kb

input:

3
1 3
2 3
3 3

output:

1
4
10

result:

ok 3 number(s): "1 4 10"

Test #2:

score: -100
Wrong Answer
time: 544ms
memory: 7600kb

input:

1
2000 2000

output:

0

result:

wrong answer 1st numbers differ - expected: '204576309', found: '0'