結果

問題 No.1694 ZerOne
ユーザー planesplanes
提出日時 2021-10-02 02:59:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 964 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 173,788 KB
実行使用メモリ 24,496 KB
最終ジャッジ日時 2023-09-27 03:05:34
合計ジャッジ時間 4,501 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 4 ms
5,692 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 3 ms
4,928 KB
testcase_08 AC 5 ms
6,716 KB
testcase_09 WA -
testcase_10 AC 3 ms
4,600 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 7 ms
7,676 KB
testcase_14 WA -
testcase_15 AC 4 ms
5,756 KB
testcase_16 AC 4 ms
5,796 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
4,404 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

vector<vector<vector<ll>>> dp;
vector<ll> A;
 string S;

ll solve(ll i,ll k,ll p) {
    if(i==0) {
        if(k==0&&p==0) return 1;
        else return 0;
    }
        
    if(dp[i][k][p+360]!=-1) {
        return dp[i][k][p+360];
    }

    ll s=0;
    if(k==0) {
        s+=solve(i-1,k,p);
    }
    else{
    for(ll j=i-1;j>=0;j--) {
        s+=solve(j,k-1,A[k-1]-j+p);
    }
    }

    dp[i][k][p+360]=s;
    return s;

}


int main() {
   cin>>S;
ll N=0;
for(ll i=0;i<S.size();i++) {
    if(S[i]=='1') N++;
}

A=vector<ll> (N);
ll now=0;
for(ll i=0;i<S.size();i++) {
    if(S[i]=='1') {
        A[now]=i;
        now++;
    }
}
/**/
dp=vector<vector<vector<ll>>> (S.size()+1,vector<vector<ll>> (N+1,vector<ll> (721,-1)));
dp[0][0][0]=1;

cout<<solve(S.size(),N,0)<<endl;
}
0