답안 #117663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
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);
  ~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 21 ms 16180 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -