Submission #389529

# Submission time Handle Problem Language Result Execution time Memory
389529 2021-04-14T07:07:19 Z wiwiho Binary Subsequences (info1cup17_binary) C++14
12.9 / 100
64 ms 31784 KB
#include <bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n"; \
}

using namespace std;

typedef long long ll;

using pii = pair<int, int>;

const ll MOD = 1000000007;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int sz = 2002;
    vector<vector<ll>> dp(sz + 1, vector<ll>(sz + 1));
    dp[1][1] = 1;
    for(int sum = 2; sum <= sz; sum++){
        for(int i = 1; i < sum; i++){
            int j = sum - i;
            dp[i][i + j] += dp[i][j];
            dp[i][i + j] %= MOD;
            dp[i + j][j] += dp[i][j];
            dp[i + j][j] %= MOD;
        }
    }

    vector<ll> ans(sz + 1);
    for(int i = 1; i <= sz; i++){
        for(int j = 1; i + j <= sz; j++){
            ans[i + j - 2] += dp[i][j];
            ans[i + j - 2] %= MOD;
        }
    }

    int T;
    cin >> T;
    while(T--){
        int n;
        cin >> n;
        cout << ans[n] << "\n-1\n";
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 63 ms 31780 KB Output is partially correct
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 31784 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 64 ms 31692 KB Output isn't correct
2 Halted 0 ms 0 KB -