Submission #117663

# Submission time Handle Problem Language Result Execution time Memory
117663 2019-06-17T05:01:31 Z 김세빈(#2878) Ljetopica (COI19_ljetopica) C++14
0 / 100
21 ms 16180 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

char S[1010], A[1010], B[1010];
ll dp[1010][1010], C[1010][1010];
ll n, k, ans;

ll f()
{
	ll i, j;

	C[n + 1][0] = 1;

	for(i=n; i>=1; i--){
		for(j=0; j<=k; j++){
			dp[i][j] = dp[i + 1][j];
			C[i][j] = C[i + 1][j];
			if((k - j & 1) ^ (S[i - 1] == 'R')) dp[i][j] = (dp[i][j] + B[n - i] * C[i + 1][j]) % mod;

			if(j){
				dp[i][j] = (dp[i][j] + dp[i + 1][j - 1]) % mod;
				C[i][j] = (C[i][j] + C[i + 1][j - 1]) % mod;
				if((k - j + 1 & 1) ^ (S[i - 1] == 'R')) dp[i][j] = (dp[i][j] + B[n - i] * C[i + 1][j - 1]) % mod;
			}
		}
	}

	return (dp[1][k] + C[1][k] * B[n]) % mod;
}

int main()
{
	ll i;

	scanf("%lld%lld", &n, &k); n --;
	scanf("%s%s%s", S, A, B);

	B[0] = 1;

	for(i=1; i<=n; i++){
		B[i] = B[i - 1] * 2 % mod;
	}

	ans = f();

	for(i=0; i<n; i++){
		S[i] = (int)'L' + 'R' - S[i];
	}

	ans = (ans + f()) % mod;

	printf("%lld\n", ans);

	return 0;
}

Compilation message

ljetopica.cpp: In function 'll f()':
ljetopica.cpp:23:10: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
    if((k - j & 1) ^ (S[i - 1] == 'R')) dp[i][j] = (dp[i][j] + B[n - i] * C[i + 1][j]) % mod;
        ~~^~~
ljetopica.cpp:28:15: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
     if((k - j + 1 & 1) ^ (S[i - 1] == 'R')) dp[i][j] = (dp[i][j] + B[n - i] * C[i + 1][j - 1]) % mod;
         ~~~~~~^~~
ljetopica.cpp: In function 'int main()':
ljetopica.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &k); n --;
  ~~~~~^~~~~~~~~~~~~~~~~~~~
ljetopica.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s%s%s", S, A, B);
  ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 16180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -