結果
| 問題 |
No.3117 Reversible Tile
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2025-04-18 20:56:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 364 ms / 3,000 ms |
| コード長 | 780 bytes |
| コンパイル時間 | 3,861 ms |
| コンパイル使用メモリ | 254,116 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-18 20:56:14 |
| 合計ジャッジ時間 | 9,501 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL
int main(){
int n,m;
cin>>n>>m;
vector<int> a(n);
rep(i,n)cin>>a[i];
a.insert(a.begin(),0);
a.push_back(0);
int ok = 0;
rep(i,a.size()-1){
if(a[i]==a[i+1])ok++;
}
n = a.size()-1;
vector<mint> dp(n+1);
dp[ok] = 1;
mint i2 = mint(2).inv();
rep(_,m){
vector<mint> ndp(n+1,0);
rep(j,n+1){
ndp[j] += dp[j] * j * (n-j);
if(j+2<=n){
ndp[j+2] += dp[j] * (n-j) * (n-j-1) * i2;
}
if(j-2>=0){
ndp[j-2] += dp[j] * j * (j-1) * i2;
}
}
swap(dp,ndp);
}
cout<<dp[n].val()<<endl;
return 0;
}
沙耶花