Submission #389492

#TimeUsernameProblemLanguageResultExecution timeMemory
389492cheissmartBinary Subsequences (info1cup17_binary)C++14
12.90 / 100
30 ms16044 KiB
#include <bits/stdc++.h> #define F first #define S second #define V vector #define PB push_back #define EB emplace_back #define MP make_pair #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << "LINE(" << __LINE__ << "): " << #x << " is " << x << endl using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7, N = 2e3 + 7, M = 1e9 + 7; int dp[N][N], ans[N]; void add(int& a, int b) { a += b; if(a >= M) a -= M; } signed main() { ios::sync_with_stdio(0), cin.tie(0); dp[0][0] = 1; for(int i = 0; i <= 2000; i++) for(int j = 0; i + j <= 2000; j++) { // add 0 if(i + j + 1 <= 2000) add(dp[i + j + 1][j], dp[i][j]); // add 1 if(i + j + 1 <= 2000) add(dp[i][i + j + 1], dp[i][j]); add(ans[i + j], dp[i][j]); } int n; cin >> n; for(int i = 0; i < n; i++) { int k; cin >> k; cout << ans[k] << '\n'; cout << -1 << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...