QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#622649#8839. Knockerucup-team2432WA 1ms3640kbC++171.8kb2024-10-08 23:41:572024-10-08 23:41:57

Judging History

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

  • [2024-10-08 23:41:57]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3640kb
  • [2024-10-08 23:41:57]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#define ll long long
#define all(v) v.begin(),v.end()
#define sz(v) ((ll)v.size())
#define V vector
#define vi V<int>
#define vll V<ll>
#define eb emplace_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define A array
#define pb push_back
#define mset multiset
#define gpumap __gnu_pbds::gp_hash_table
#define ccumap __gnu_pbds::cc_hash_table
#define ui unsigned int
#define ull unsigned ll
#define i128 __int128
#define cerr if (test) cerr
#define freopen if (test) freopen
#define whtest if (test)
using namespace std;

const int test = 0;

namespace jhsy {
	const int P = 998244353;
	template<class T>
	void wadd(T &a,const T &b) {
		a = (a+b)%P;
	}
	void wadd(int &a,const int &b) {
		a += b;
		if (a >= P) {
			a -= P;
		}
	}
	void main() {
		int n;
		cin >> n;
		vi a(n);
		for (auto &x:a) {
			cin >> x;
		}
		sort(all(a));
		a.erase(unique(all(a)),a.end());
		n = sz(a);
		const int m = a.back();
		vi vis(m+1);
		for (auto x:a) {
			vis[x] = 1;
		}
		V<vi> f(m+1+1,vi(m+1));
		f[m+1][0] = 1;
		int ans = 0;
		for (int i = m+1; i >= 0; i--) {
			for (int j = 0; j <= m; j++) {
				if (f[i][j]) {
					ans = (ans+f[i][j])%P;
					for (int k = i-1,mx = -1; k >= max(j+1,(mx+1)/2); k--) {
						if (vis[k] && mx == -1) {
							mx = k;
						}
						if (mx != -1) {
							wadd(f[k][max(j,mx-k)],f[i][j]);
						}
					}
				}
			}
		}
		cout << ans << '\n';
	}
}

int main() {
	freopen("test.in","r",stdin);
	freopen("test.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);

//	jhsy::init();

	int T = 1;
//	cin >> T;
	while (T--) {
		jhsy::main();
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

1
5

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3580kb

input:

2
6 5

output:

8

result:

wrong answer 1st numbers differ - expected: '7', found: '8'