結果

問題 No.1856 Mex Sum 2
ユーザー 蜜蜂蜜蜂
提出日時 2022-02-23 10:10:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,002 ms / 3,000 ms
コード長 1,728 bytes
コンパイル時間 4,998 ms
コンパイル使用メモリ 237,360 KB
実行使用メモリ 19,380 KB
最終ジャッジ日時 2023-09-14 02:26:05
合計ジャッジ時間 34,772 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 202 ms
6,512 KB
testcase_30 AC 105 ms
5,148 KB
testcase_31 AC 195 ms
6,484 KB
testcase_32 AC 295 ms
7,756 KB
testcase_33 AC 337 ms
8,796 KB
testcase_34 AC 195 ms
6,436 KB
testcase_35 AC 108 ms
4,980 KB
testcase_36 AC 48 ms
4,376 KB
testcase_37 AC 188 ms
6,448 KB
testcase_38 AC 36 ms
4,380 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 5 ms
4,376 KB
testcase_41 AC 6 ms
4,376 KB
testcase_42 AC 943 ms
18,180 KB
testcase_43 AC 785 ms
15,164 KB
testcase_44 AC 850 ms
16,376 KB
testcase_45 AC 927 ms
17,940 KB
testcase_46 AC 806 ms
15,236 KB
testcase_47 AC 875 ms
16,576 KB
testcase_48 AC 964 ms
18,544 KB
testcase_49 AC 951 ms
18,292 KB
testcase_50 AC 671 ms
13,064 KB
testcase_51 AC 993 ms
19,292 KB
testcase_52 AC 983 ms
19,056 KB
testcase_53 AC 992 ms
19,168 KB
testcase_54 AC 998 ms
19,156 KB
testcase_55 AC 996 ms
19,164 KB
testcase_56 AC 996 ms
19,376 KB
testcase_57 AC 995 ms
19,188 KB
testcase_58 AC 996 ms
19,224 KB
testcase_59 AC 995 ms
19,224 KB
testcase_60 AC 997 ms
19,260 KB
testcase_61 AC 997 ms
19,380 KB
testcase_62 AC 998 ms
19,204 KB
testcase_63 AC 996 ms
19,220 KB
testcase_64 AC 1,002 ms
19,332 KB
testcase_65 AC 997 ms
19,144 KB
testcase_66 AC 994 ms
19,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//g++ 3.cpp -std=c++14 -O2 -I .
#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vst = vector<string>;
using vvst = vector<vst>;

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define pq_big(T) priority_queue<T,vector<T>,less<T>>
#define pq_small(T) priority_queue<T,vector<T>,greater<T>>
#define all(a) a.begin(),a.end()
#define rep(i,start,end) for(ll i=start;i<(ll)(end);i++)
#define per(i,start,end) for(ll i=start;i>=(ll)(end);i--)
#define uniq(a) sort(all(a));a.erase(unique(all(a)),a.end())

using mint = modint998244353;
constexpr ll mod = 998244353;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  ll n,m;
  cin>>n>>m;

  ll mx=min(n,m+1);

  mint pw[mx+1][n+1]={}; // pw[i][j] := (M+1-i)^(N-k)
  rep(i,0,mx+1){
    pw[i][n]=1;
    per(j,n-1,0){
      pw[i][j]=pw[i][j+1]*(m+1-i);
    }
  }

  mint pw2[n+1]={}; // pw2[i] := 2^i
  pw2[0]=1;
  rep(i,1,n+1){
    pw2[i]=pw2[i-1]*2;
  }

  mint fac[n+1]={}; // fac[i] := i!
  fac[0]=1;
  rep(i,1,n+1){
    fac[i]=fac[i-1]*i;
  }

  vll fp(n+1,0);
  rep(i,1,n+1){
    mint now=pw2[i]-1;
    now/=(pw2[i]*fac[i]);
    fp[i]=now.val();
  }

  mint ans=0;

  vll fp_now={1};

  rep(i,1,mx+1){
    fp_now=convolution(fp_now,fp);
    rep(j,0,n+1){
      mint now=1;
      now/=fac[n-j];
      now*=pw[i][j];
      now*=fp_now[j];

      ans+=now;
    }

    while(fp_now.size()>n+5){
      fp_now.pop_back();
    }
  }

  ans*=pw2[n];
  ans*=fac[n];

  cout<<ans.val()<<endl;
}
0