This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
#define forb(i,a,b) for(int i = a; i>=b; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
using namespace std;
ll mod = 1000000007;
ll binom[2001][2001];
ll dig[2001];
int N,K;
char ts[2001],tl[2001];
int A[2001];
int S[2001],L[2001];
void calc(){
binom[0][0] = 1; binom[1][0] = 1; binom[1][1] = 1;
forf(i,2,N){
binom[i][0] = 1;
forf(j,1,i){
binom[i][j] = (binom[i-1][j-1]+binom[i-1][j]) % mod;
}
}
dig[N-1] = 1;
forb(i,N-2,0){
dig[i] = dig[i+1] * 2 % mod;
}
}
int main(){
scanf("%d %d" , &N,&K);
forf(i,1,N-1){
char c; scanf("%c" , &c);
if(c=='L') A[i] = 0;
else A[i] = 1;
}
scanf("%s %s" , ts,tl);
forf(i,0,N-1){
if(ts[i] == '0') S[i] = 0;
else S[i] = 1;
if(tl[i] == '0') L[i] = 0;
else L[i] = 1;
}
calc();
ll ans = dig[0]*2*binom[N-1][K] % mod;
forf(i,1,N-1){
int l = i;
int r = N-1-i;
forf(j,0,K){
ans += dig[i]*binom[l][j] %mod *binom[r][K-j] %mod;
ans %= mod;
}
}
printf("%lld" , ans);
}
Compilation message (stderr)
ljetopica.cpp: In function 'int main()':
ljetopica.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
30 | scanf("%d %d" , &N,&K);
| ~~~~~^~~~~~~~~~~~~~~~~
ljetopica.cpp:32:22: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | char c; scanf("%c" , &c);
| ~~~~~^~~~~~~~~~~
ljetopica.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | scanf("%s %s" , ts,tl);
| ~~~~~^~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |