結果

問題 No.1694 ZerOne
ユーザー monnumonnu
提出日時 2021-10-01 21:48:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 3,935 ms
コンパイル使用メモリ 231,216 KB
実行使用メモリ 57,208 KB
最終ジャッジ日時 2023-09-26 16:58:19
合計ジャッジ時間 5,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 9 ms
10,864 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,784 KB
testcase_09 AC 10 ms
11,884 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 4 ms
6,072 KB
testcase_14 AC 11 ms
12,180 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 57 ms
57,208 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 53 ms
55,120 KB
testcase_24 AC 16 ms
17,160 KB
testcase_25 AC 15 ms
16,848 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 42 ms
44,520 KB
testcase_28 AC 10 ms
11,692 KB
testcase_29 AC 4 ms
5,572 KB
testcase_30 AC 9 ms
10,528 KB
testcase_31 AC 12 ms
13,692 KB
testcase_32 AC 17 ms
17,768 KB
testcase_33 AC 15 ms
16,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
#define INF 1000000000
#define MOD 998244353
#define MAX 200000

int main(){
  string S;
  cin>>S;
  int N=S.size();
  int cnt=0;
  int sum=0;
  for(int i=0;i<N;i++){
    if(S[i]=='1'){
      cnt++;
      sum+=i+1;
    }
  }
  vector<vector<vector<ll>>> dp(N+1,vector<vector<ll>>(cnt+1,vector<ll>(sum+1,0)));
  dp[0][0][0]=1;
  for(int i=0;i<N;i++){
    for(int j=0;j<=cnt;j++){
      for(int k=0;k<=sum;k++){
        dp[i+1][j][k]+=dp[i][j][k];
        if(j+1<=cnt&&k+(i+1)<=sum){
          dp[i+1][j+1][k+(i+1)]+=dp[i][j][k];
        }
      }
    }
  }
  cout<<dp[N][cnt][sum]<<'\n';
}
0