結果

問題 No.1694 ZerOne
ユーザー tnakao0123tnakao0123
提出日時 2021-10-05 16:05:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,147 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 91,364 KB
実行使用メモリ 52,856 KB
最終ジャッジ日時 2023-09-30 08:31:55
合計ジャッジ時間 2,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,640 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
7,748 KB
testcase_03 AC 12 ms
46,484 KB
testcase_04 AC 3 ms
11,728 KB
testcase_05 AC 7 ms
28,112 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 6 ms
23,992 KB
testcase_08 AC 7 ms
30,168 KB
testcase_09 AC 12 ms
44,476 KB
testcase_10 AC 6 ms
24,024 KB
testcase_11 AC 2 ms
5,656 KB
testcase_12 AC 2 ms
7,560 KB
testcase_13 AC 8 ms
32,196 KB
testcase_14 AC 12 ms
44,424 KB
testcase_15 AC 7 ms
28,040 KB
testcase_16 AC 6 ms
26,100 KB
testcase_17 AC 3 ms
11,736 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 12 ms
52,684 KB
testcase_21 AC 19 ms
52,776 KB
testcase_22 AC 11 ms
52,696 KB
testcase_23 AC 18 ms
52,856 KB
testcase_24 AC 14 ms
52,700 KB
testcase_25 AC 13 ms
52,676 KB
testcase_26 AC 11 ms
50,652 KB
testcase_27 AC 16 ms
50,624 KB
testcase_28 AC 11 ms
42,568 KB
testcase_29 AC 10 ms
44,504 KB
testcase_30 AC 11 ms
46,560 KB
testcase_31 AC 13 ms
50,700 KB
testcase_32 AC 13 ms
48,600 KB
testcase_33 AC 13 ms
50,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1694.cc:  No.1694 ZerOne - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 60;
const int MAX_M = MAX_N * (MAX_N - 1) / 2;

/* typedef */

typedef long long ll;

/* global variables */

char s[MAX_N + 4];
ll dp[MAX_N + 1][MAX_N + 1][MAX_M + 1];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int n = strlen(s);

  int on = 0, m = 0;
  for (int i = 0; i < n; i++) {
    int si = s[i] - '0';
    on += si;
    m += si * i;
  }
  //printf("on=%d, m=%d\n", on, m);

  dp[0][0][0] = 1;

  for (int i = 0; i < n; i++)
    for (int j = 0; j <= on; j++)
      for (int k = 0; k <= m; k++)
	if (dp[i][j][k] > 0) {
	  dp[i + 1][j][k] += dp[i][j][k];
	  if (j < on && k + i <= m)
	    dp[i + 1][j + 1][k + i] += dp[i][j][k];
	}

  printf("%lld\n", dp[n][on][m]);
  return 0;
}
0