結果
| 問題 | No.3777 Train Seats |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-24 01:00:02 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 4 ms / 2,000 ms |
| + 608µs | |
| コード長 | 1,004 bytes |
| 記録 | |
| コンパイル時間 | 1,503 ms |
| コンパイル使用メモリ | 197,220 KB |
| 実行使用メモリ | 21,688 KB |
| 最終ジャッジ日時 | 2026-10-24 01:00:07 |
| 合計ジャッジ時間 | 4,297 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
16 | main() {
| ^~~~
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
using namespace std;
const long long MOD=998244353;
long long f[1001][1001],ft[1001][1001],c[1001][1001];
long long fc[1001];
long long ans[1001];
bool added[1001][1001];
main() {
long long q;
cin>>q;
ft[1][1]=1;
ft[2][1]=1;
for (int n=3;n<=q;n++) {
for (int j=1;j<=n;j++) {
ft[n][j]=(ft[n-3][j-1]+ft[n-2][j-1])%MOD;
}
}
for (int n=1;n<=q;n++)
for (int i=1;i<=n;i++)
{
f[n][i]=(ft[n][i]+ft[n-1][i])%MOD;
//printf("ft[%d][%d]=%d\n",n,i,ft[n][i]);
}
fc[0]=1;
for (long long x=1;x<=q;x++)
fc[x]=(fc[x-1]*x)%MOD;
for (int n=q;n<=q;n++) {
ans[n]=0;
for (int i=0;i<=n;i++)
if (f[n][i]) {
ans[n]+=(((f[n][i]*fc[i])%MOD) * fc[n-i])%MOD;
ans[n]%=MOD;
}
}
cout<<ans[q]<<endl;
}