#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
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);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
16728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
16732 KB |
Output is correct |
2 |
Correct |
13 ms |
16732 KB |
Output is correct |
3 |
Correct |
15 ms |
16732 KB |
Output is correct |
4 |
Correct |
20 ms |
16732 KB |
Output is correct |
5 |
Correct |
12 ms |
16728 KB |
Output is correct |
6 |
Correct |
20 ms |
16732 KB |
Output is correct |
7 |
Correct |
10 ms |
16728 KB |
Output is correct |
8 |
Correct |
14 ms |
16928 KB |
Output is correct |
9 |
Correct |
6 ms |
16732 KB |
Output is correct |
10 |
Correct |
13 ms |
16732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
16728 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |