結果
問題 |
No.1694 ZerOne
|
ユーザー |
![]() |
提出日時 | 2021-10-04 04:14:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 1,503 bytes |
コンパイル時間 | 3,294 ms |
コンパイル使用メモリ | 182,516 KB |
最終ジャッジ日時 | 2025-01-24 20:12:28 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #include <list> #include <atcoder/all> #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair<int, int> P; using mint=modint998244353; ll dp[61][61][2000]; int main() { string s; cin>>s; int n=s.size(); bool dame=1; for(int i=0; i<n-1; i++){ for(int j=i+2; j<n-1; j++){ if(s[i]=='0' && s[i+1]=='1' && s[j]=='1' && s[j+1]=='0'){ dame=0; } if(s[i]=='1' && s[i+1]=='0' && s[j]=='0' && s[j+1]=='1'){ dame=0; } } } if(dame){ cout<<1<<endl; return 0; } int c=0; int d=0; for(int i=0; i<n; i++){ if(s[i]=='1'){ c++; d+=i+1; } } dp[0][0][0]=1; for(int i=0; i<n; i++){ for(int j=0; j<=i; j++){ for(int k=0; k<=i*(i+1)/2; k++){ dp[i+1][j][k]+=dp[i][j][k]; dp[i+1][j+1][k+i+1]+=dp[i][j][k]; } } } cout<<dp[n][c][d]<<endl; return 0; }