Gym - 101652W

蓝色左上只能是蓝色,红色右下只能是红色。
其实只要考虑一种就可以了,因为考虑了一种颜色 ,另一种就会和他叠起来。‘

#include<cstring>
#include<cstdio>

using namespace std;
typedef long long ll;
char s[40][40];
ll dp[40][40];
int a[40][40];
int n, m;

int check(int x, int y)
{
    for(int i = 1; i <= y; i++)
        if(s[x][i] == 'R')
        return 0;
    for(int i = y + 1; i <= m; i++)
        if(s[x][i] == 'B')
        return 0;
    return 1;
}

int main()
{
    while(~scanf("%d%d", &n, &m))
    {
        for(int i = 1; i <= n; i++)
            scanf("%s", s[i] + 1);
        memset(dp, 0, sizeof(dp));
        memset(a, 0, sizeof(a));
        for(int i = 1; i <= n; i++)
        {
            for(int j = 0; j <= m; j++)
                a[i][j] = check(i, j);
        }
        for(int i = 0; i <= m; i++) dp[1][i] = a[1][i];
        for(int i = 2; i <= n; i++)
        {
            for(int j =0; j <= m; j++)
                for(int k = 0; k <= j; k++)
                dp[i][k] += dp[i - 1][j] * a[i][k];

        }
        ll ans = 0;
        for(int i = 0; i <= m; i++) ans += dp[n][i];
        printf("%lld\n", ans);
    }
    return 0;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
wandb: Tracking run with wandb version 0.15.5 wandb: W&B syncing is set to `offline` in this directory. wandb: Run `wandb online` or set WANDB_MODE=online to enable cloud syncing. /home/zhangmengjie/anaconda3/envs/torch1/lib/python3.7/site-packages/gym/envs/registration.py:556: UserWarning: WARN: The environment Ant-v2 is out of date. You should consider upgrading to version `v4`. f"The environment {id} is out of date. You should consider " Error compiling Cython file: ------------------------------------------------------------ ... See c_warning_callback, which is the C wrapper to the user defined function ''' global py_warning_callback global mju_user_warning py_warning_callback = warn mju_user_warning = c_warning_callback ^ ------------------------------------------------------------ /home/zhangmengjie/anaconda3/envs/torch1/lib/python3.7/site-packages/mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil' Error compiling Cython file: ------------------------------------------------------------ ... See c_warning_callback, which is the C wrapper to the user defined function ''' global py_error_callback global mju_user_error py_error_callback = err_callback mju_user_error = c_error_callback ^ ------------------------------------------------------------ /home/zhangmengjie/anaconda3/envs/torch1/lib/python3.7/site-packages/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil' Compiling /home/zhangmengjie/anaconda3/envs/torch1/lib/python3.7/site-packages/mujoco_py/cymj.pyx because it changed. [1/1] Cythonizing /home/zhangmengjie/anaconda3/envs/torch1/lib/python3.7/site-packages/mujoco_py/cymj.pyx wandb: Waiting for W&B process to finish... (failed 1). wandb: You can sync this run to the cloud by running: wandb: wandb sync /home/zhangmengjie/PID/Python/ERL-Re2-main/wandb/offline-run-20230721_165346-awq1hazo wandb: Find logs at: ./wandb/offline-run-20230721_165346-awq1hazo/logs
最新发布
07-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值