結果

問題 No.1963 Subset Mex
ユーザー 👑 tute7627tute7627
提出日時 2022-04-18 22:30:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,326 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 205,804 KB
実行使用メモリ 8,104 KB
最終ジャッジ日時 2023-08-28 19:14:38
合計ジャッジ時間 13,731 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 333 ms
7,888 KB
testcase_02 AC 334 ms
7,816 KB
testcase_03 AC 333 ms
7,896 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 333 ms
7,932 KB
testcase_27 AC 334 ms
7,972 KB
testcase_28 AC 333 ms
7,812 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;

using modint = atcoder::modint998244353;

const int SZ = 105;
modint dp[SZ][SZ][SZ];

int main(){

  int N;
  cin >> N;
  vector<int> S(N);
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  vector<int> C(SZ);
  for(int i = 0; i < N; i++){
    C[S[i]]++;
  }
  
  memset(dp, 0, sizeof(dp));
  dp[SZ - 1][0][0] = 1;
  modint ans = 0;

  for(int i = SZ - 2; i >= 0; i--){
    int require = 0;
    vector<int>f(i + 1);
    f[max(0, i - 1)] = 1;
    for(int j = i - 1; j >= 1; j--){
      int use = min(f[j], C[j]);
      f[j - 1] = 2 * f[j] - use;
      f[j - 1] = min(f[j - 1], 10000);
      require -= C[j] - use;
    }
    require += f[0] - C[0];
    for(int j = 0; j < SZ; j++){
      for(int k = 0; k < SZ; k++){
        for(int num = 0; num < SZ; num++){
          int use = min(j + num, C[i]);
          int nj = 2 * j + num - use;
          int nk = k + C[i] - use;
          if(i == 0 && nj > 0 && j + num <= C[i] + k){
            ans += dp[i+1][j][k];
          }
          if(nj < SZ && nk < SZ){
            dp[i][nj][nk] += dp[i+1][j][k];
          }
          if(nj == 0 && num > 0 && nk >= require - 1){
            ans += dp[i+1][j][k];
          }
        }
      }
    }
  }
  cout << ans.val() + 1 << endl;
}
0