結果

問題 No.1608 Yet Another Ants Problem
ユーザー rtyurtyu
提出日時 2021-07-16 22:42:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,061 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 67,984 KB
実行使用メモリ 74,120 KB
最終ジャッジ日時 2023-09-20 15:04:38
合計ジャッジ時間 5,472 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 195 ms
74,044 KB
testcase_15 AC 195 ms
74,008 KB
testcase_16 AC 195 ms
73,952 KB
testcase_17 AC 194 ms
73,996 KB
testcase_18 AC 193 ms
73,912 KB
testcase_19 AC 21 ms
22,684 KB
testcase_20 AC 88 ms
50,132 KB
testcase_21 AC 85 ms
50,132 KB
testcase_22 AC 58 ms
39,596 KB
testcase_23 AC 185 ms
73,064 KB
testcase_24 WA -
testcase_25 AC 201 ms
73,980 KB
testcase_26 AC 201 ms
73,980 KB
testcase_27 AC 202 ms
74,120 KB
testcase_28 AC 202 ms
74,060 KB
testcase_29 AC 201 ms
73,944 KB
testcase_30 AC 186 ms
73,896 KB
testcase_31 AC 186 ms
74,112 KB
testcase_32 AC 186 ms
73,952 KB
testcase_33 AC 186 ms
74,080 KB
testcase_34 AC 186 ms
73,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

int a[3009];
long long cb[3009][3009], ans[3009], md = 998244353;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, l; cin >> n >> l;
	cb[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		cb[i][0] = 1;
		for (int j = 1; j <= n; j++)
			cb[i][j] = (cb[i - 1][j - 1] + cb[i - 1][j]) % md;
	}
	for (int i = 1; i <= n; i++) {
		for (int pi = 0; pi < 2; pi++) {
			int c = n - 1, lc = 0, rc = 0, h = a[i];
			if (pi) h = l - a[i];
			bool f = true;
			for (int j = 1; j <= n; j++) {
				if (i == j) continue;
				bool lf = (a[j] <= h), rf = ((l - a[j]) <= h);
				if (j > i) {
					if (a[j] == h) lf = false;
					if (l - a[j] == h) rf = false;
				}
				if (!lf && !rf) {
					f = false;
					break;
				}
				else if (!lf || !rf) {
					c--;
					if (!lf) rc++;
					else lc++;
				}
			}
			if (!f) continue;
			for (int j = 0; j <= c; j++) 
				ans[lc + j + 1] = (ans[lc + j + 1] + cb[c][j]) % md;
		}
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << '\n';
	return 0;
}
0