Submission #1139546

#TimeUsernameProblemLanguageResultExecution timeMemory
1139546KasymKBinary Subsequences (info1cup17_binary)C++20
0 / 100
48 ms63044 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} const int N = 2005; const int MOD = 1e9+7; int dp[N][N]; int f(int k, int x, int y){ if(x<0 or y<0) return 0; if(k==1 and x==0 and y==0) return 1; if(dp[x][y]==-1) (dp[x][y]=f(x, x-y-1, y)+f(y, x, y-x-1))%=MOD; return dp[x][y]; } int main(){ memset(dp, -1, sizeof dp); int tt; scanf("%d", &tt); int op=1; while(tt--){ int k; scanf("%d", &k), k++; int answer=0; for(int i = 0; i < k; ++i) (answer+=f(k, i, k-i-1))%=MOD; printf("%d\n", answer); if(op==1) puts("0"); else if(op==2) puts("0 0"); else if(op==3) puts("1 0"); else if(op==6) puts("1 0 1"); else if(op==8) puts("1 1 0 0"); else if(op==19) printf("1 0 1 0 1"); else puts("-1"); op++; } return 0; }

Compilation message (stderr)

binary.cpp: In function 'int main()':
binary.cpp:32:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         scanf("%d", &tt);
      |         ~~~~~^~~~~~~~~~~
binary.cpp:36:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |                 scanf("%d", &k), k++;
      |                 ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...