結果

問題 No.1608 Yet Another Ants Problem
ユーザー rtyurtyu
提出日時 2021-07-16 22:47:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 1,058 bytes
コンパイル時間 860 ms
コンパイル使用メモリ 67,680 KB
実行使用メモリ 74,232 KB
最終ジャッジ日時 2023-09-20 15:10:49
合計ジャッジ時間 5,537 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 193 ms
73,940 KB
testcase_15 AC 192 ms
74,004 KB
testcase_16 AC 192 ms
73,964 KB
testcase_17 AC 193 ms
74,232 KB
testcase_18 AC 192 ms
74,000 KB
testcase_19 AC 21 ms
22,712 KB
testcase_20 AC 86 ms
50,104 KB
testcase_21 AC 84 ms
50,096 KB
testcase_22 AC 57 ms
39,740 KB
testcase_23 AC 185 ms
73,052 KB
testcase_24 AC 191 ms
73,940 KB
testcase_25 AC 201 ms
74,032 KB
testcase_26 AC 201 ms
73,964 KB
testcase_27 AC 201 ms
73,944 KB
testcase_28 AC 202 ms
74,016 KB
testcase_29 AC 200 ms
73,968 KB
testcase_30 AC 178 ms
74,004 KB
testcase_31 AC 178 ms
73,968 KB
testcase_32 AC 178 ms
74,148 KB
testcase_33 AC 179 ms
73,976 KB
testcase_34 AC 178 ms
73,976 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 (pi) {
					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